【发布时间】:2018-01-16 07:40:37
【问题描述】:
我正在尝试找到一种方法,使用 PowerShell 从 Bamboo 部署服务器脚本任务将应用服务更新部署到 Azure 应用服务。
我遇到了身份验证部分的问题。
注意:感谢https://markheath.net/post/deploy-azure-webapp-kudu-zip-api 提供脚本创意。
下面是我的 PowerShell 脚本。
$PublishingUsername = ["The value of the userName property name in the Azure PublishSettings file"]
$PublishingPassword = ["The value of the userPWD property name in the Azure PublishSettings file"]
$SlotName = ["The name of the slot. I.e. qa"]
$WebAppName = ["The name of the app service in Azure"]
$LocalPath = ["The location of zip file that holds the VS2017 Publish Output files"]
function Upload-ZipDeploy() {
$pair = "$($PublishingUsername):$($PublishingPassword)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{
Authorization = $basicAuthValue
}
if ($SlotName -eq ""){
$kuduApiUrl = "https://$WebAppName.scm.azurewebsites.net/api/zipdeploy"
}
else{
$kuduApiUrl = "https://$WebAppName`-$SlotName.scm.azurewebsites.net/api/zipdeploy"
}
# use kudu deploy from zip file
Invoke-WebRequest -Uri $kuduApiUrl -Headers $Headers `
-InFile $LocalPath -ContentType "multipart/form-data" -Method Post
}
Upload-ZipDeploy
当我运行这个脚本时,我得到了
Invoke-WebRequest : Server Error
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the
credentials that you supplied.
我正在使用我为 Azure 中的应用服务部署槽设置下载的 *.PublishSettings 文件中的 userName 和 userPWD 值。我可以在 VS2017 的发布向导中导入相同的 *.PublishSettings 文件并成功发布到该插槽。我似乎无法在 PowerShell 中执行此操作。
我在这里错过了什么?
【问题讨论】:
标签: powershell azure bamboo kudu azure-app-service-envrmnt