Azure-创建部署槽node.js-ResourceNotFound

问题描述 投票:0回答:1

我正在尝试使用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”。

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

我在做什么错?

谢谢

azure azure-web-sites
1个回答
0
投票

如果要为Web应用程序创建部署插槽,则需要使用createOrUpdateSlot方法,note createOrUpdateSlot必须与Web应用程序相同。

样本

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();

© www.soinside.com 2019 - 2024. All rights reserved.