【问题标题】:Azure - create deployment slot node.js - ResourceNotFoundAzure - 创建部署槽 node.js - ResourceNotFound
【发布时间】:2020-05-12 15:02:31
【问题描述】:

我正在尝试使用 node.js SDK(npm 包@azure/arm-appservice)在 Azure 上创建一个部署槽

这就是我调用方法的方式:

const msRest = require('@azure/ms-rest-nodeauth');
const armWebsite = require('@azure/arm-appservice');

async function createDeploymentSlot(){
    const credentials = await msRest.loginWithServicePrincipalSecret("clientId", "secret", "domain");
    const webManagementClient = armWebsite.WebSiteManagementClient(credentials, "subscriptionId");
    const deployment = {
        location : "westus"
    }

    return webManagementClient.webApps.createDeploymentSlot(
        "test-resource-group-name", 
        "test-app-name", 
        "", //ID of an existing deployment??
        "test-new-slot-name", 
        deployment
    )
}

我收到以下错误:

错误:找不到资源组“test-resource-group-name”下的资源“Microsoft.Web/sites/test-app-name/slots/test-new-slot-name”。

这很奇怪,因为它说找不到我要创建的资源。

我做错了什么?

谢谢

【问题讨论】:

    标签: node.js azure azure-web-app-service


    【解决方案1】:

    如果你想为你的网络应用创建一个部署槽,你需要使用createOrUpdateSlot方法,注意location需要和网络应用一样。

    示例

    const msRest = require('@azure/ms-rest-nodeauth');
    const armWebsite = require('@azure/arm-appservice');
    
    async function main(){
        const credentials = await msRest.loginWithServicePrincipalSecret("clientId", "secret", "domain");
        const webManagementClient = new armWebsite.WebSiteManagementClient(credentials, "subscriptionId");
    
        const siteEnvelope = '{"location":"centralus","enabled":true}';
        const obj = JSON.parse(siteEnvelope);
    
        const a = await webManagementClient.webApps.createOrUpdateSlot(
            "groupname",
            "joywebapp",
            obj,
            "slot2"
        );
        console.log(a)
    
    }
    main();
    

    【讨论】:

    • 我昨天找到并实施了确切的解决方案,因此我可以验证这确实有效。令人沮丧的是 Azure 文档可能会如此误导。谢谢:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-26
    • 1970-01-01
    相关资源
    最近更新 更多