Azure webapp 在创建后添加 deploymentLocalGitUrl

Azure webapp add deploymentLocalGitUrl after create

我正在尝试 https://docs.microsoft.com/nl-nl/azure/app-service/app-service-web-get-started-html,当然,我不会一字不漏。

我已经有一个网络应用程序(以及资源​​计划和其他东西)。我只想添加本地 git 内容。当我在 CLI 中列出应用程序的属性时,应该有这个 属性 deploymentLocalGitUrl,但它不在那里。如何通过 CLI 或仪表板添加它?

提前致谢。

干杯,埃里克!

这是正常情况。

根据我的测试,您可以参考屏幕截图。

我用--deployment-local-git创建了一个网络应用程序,我们可以在运行结果中找到deploymentLocalGitUrl

然后我使用 az webapp show -n <webappname> -g <resourcegroupname> 来获取网络应用程序的属性。我们不会看到 deploymentLocalGitUrl.

但我们可以在 Azure 门户中找到它。

因此,如果您想添加 属性,您可以在 Azure 门户中进行设置。

设置好之后就可以找到上面截图中提到的属性

gitdirectory=<Replace with path to local Git repo>
username=<Replace with desired deployment username>
password=<Replace with desired deployment password>

在 Azure 上创建 webapp 后,通过 git 配置网站部署。设置帐户级部署凭据。

$ az webapp deployment user set --user-name $username --password $password

此命令将 return Git 端点推送到其中包括用户名。

$ az webapp deployment source config-local-git --name mywebapp --resource-group myResourceGroup

它return如下:

{
  "url": "https://username@mywebapp.scm.azurewebsites.net/mywebapp.git"
}

有了端点,cd 到 git 存储库并在 Git 中设置一个名为 azure 的新远程。

$ cd $gitdirectory    //remember to git init before you cd

$ git remote add azure https://username@mywebapp.scm.azurewebsites.net/mywebapp.git

最后,您可以将应用程序部署到 Azure。

git push azure master

您可以在门户中看到的属性如下:

更多细节,你可以参考这篇article and this one