Azure Cloud shell 使用发布配置文件发布 Web 应用程序

标签 azure azure-web-app-service azure-cloud-shell publish-profiles

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, using az login ...

当您使用azure cloud shell时,它会自动使用登录azure门户的帐户,因此无需使用az login登录再次,只需使用命令 az webapp up直接地。您应该注意,命令 az webapp up 需要从代码所在的文件夹运行,因此您可能需要先将代码上传到cloud shell(我没有测试过,不确定它是否可以在cloud shell中运行。)

enter image description here

实际上,如果您想使用发布配置文件部署 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/

相关文章:

python - 使用 REST API 获取 Azure 事件中心指标?

azure - 如何限制服务主体对 ADLS Gen2 中特定文件夹的访问?

azure - 用户对使用 Azure AD 保护的 Web 应用程序的访问/授权

c# - 如何识别重复的应用程序 list 证书

Azure CosmosDB 存储过程将函数参数更改为较小的大小写

Azure Web应用程序未处理的异常

Azure Functions 可扩展性问题

azure - 移动 Azure 中云控制台的位置

azure - 如何获取仅包含 Azure 区域名称的列表?

azure - 无法配置云 shell,Azure 错误