Azure Cloud Shell 无法导入可从 Azure 中的 Web 应用程序概述导出的发布配置文件(即“MyWebApp.PublishSettings”),该配置文件可在 Visual Studio 中用于发布网络应用程序。我正在尝试查找使用 Azure Cloud Shell 执行的命令(可能是 az webapp up ...
),但它要求我首先使用 az login ...
登录。 。对于 Visual Studio,发布配置文件 文件就足够了,无需登录。如何像 Visual Studio 一样使用发布配置文件进行发布,但使用 Azure Cloud Shell?
最佳答案
I am trying to find the commands to execute with the Azure Cloud Shell (
az webapp up
... perhaps), but it requires me to sign in first, usingaz login ...
当您使用azure cloud shell时,它会自动使用登录azure门户的帐户,因此无需使用az login
登录再次,只需使用命令 az webapp up
直接地。您应该注意,命令 az webapp up
需要从代码所在的文件夹运行,因此您可能需要先将代码上传到cloud shell(我没有测试过,不确定它是否可以在cloud shell中运行。)
实际上,如果您想使用发布配置文件部署 Web 应用程序,我推荐的最简单方法是 use the kudu api via powershell在本地,只需在本地打开一个powershell session 并运行以下命令,您就可以找到$password
在发布配置文件中。
$username = "`$webappname"
$password = "xxxxxxx"
# Note that the $username here should look like `SomeUserName`, and **not** `SomeSite\SomeUserName`
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$userAgent = "powershell/1.0"
$apiUrl = "https://joywebapp.scm.azurewebsites.net/api/zipdeploy"
$filePath = "C:\Users\joyw\Desktop\testdep.zip"
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method POST -InFile $filePath -ContentType "multipart/form-data"
关于Azure Cloud shell 使用发布配置文件发布 Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63961729/