0

我在azure定时器触发的函数中有以下代码。它所做的只是通过服务主体方法在 Azure 中创建日志并调用 Azure API 来建立资源。

函数记录直到“登录”。不会再进一步​​,也不会记录日志记录成功或失败。我错过了什么?

module.exports = function (context, myTimer) {
    var timeStamp = new Date().toISOString();
    context.log("time triggered function entry")

    const ACI   = require('azure-arm-containerinstance');
    const AZ    = require('ms-rest-azure');

    context.log('Starting a container');

    if(process.env.AZURE_CLIENT_ID) {
        var client_id = process.env.AZURE_CLIENT_ID;
    }
    else {
        var client_id = "";
    }

    if(process.env.AZURE_CLIENT_SECRET) {
        var client_secret = process.env.AZURE_CLIENT_SECRET;
    }
    else {
        var client_secret = "";
    }

    if(process.env.TENANT_ID) {
        var tenant_id = process.env.TENANT_ID;
    }
    else {
        var tenant_id = "";
    }

    if(process.env.SUBSCRIPTION_ID) {
        var subscription_id = process.env.SUBSCRIPTION_ID;
    } else {
        var subscription_id = "";
    }

    if(process.env.RESOURCE_GROUP) {
        var resource_group = process.env.RESOURCE_GROUP;
    } else {
        var resource_group = "testAppDeployment";
    }

    if(process.env.CONTAINER_IMAGE_NAME) {
        var containerImageName = process.env.CONTAINER_IMAGE_NAME;
    } else {
        var containerImageName = "<some-containername";
    }

    if(process.env.DEFAULT_REGION) {
        var location = process.env.DEFAULT_REGION;
    } else {
        var location = "eastus"
    }
    var containerGroup = resource_group + "containerGroup";
    var containerName = "tempname";

    context.log("Logging in")
    context.log("tenant id: " + tenant_id)
    context.log("client id: " + client_id)
    context.log("client secret: " + client_secret)

    AZ.loginWithServicePrincipalSecret(
    client_id,
    client_secret,
    tenant_id,
    (err, credentials) = {
        if (err) {
        context.log("logging failed")
        throw err;
    }
    let client = new ACI(credentials, subscription_id);
    context.log("logging succeeded")
    }
}
4

0 回答 0