如何从Bamboo部署服务器中使用Azure kudu zipdeploy [英] How to use Azure kudu zipdeploy from a Bamboo deployment server

查看:145
本文介绍了如何从Bamboo部署服务器中使用Azure kudu zipdeploy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一种使用PowerShell从Bamboo部署服务器脚本任务将应用程序服务更新部署到Azure应用程序服务的方法。

I am trying to find a way to deploy an app service update to an Azure app service from a Bamboo deployment server script task using PowerShell.

我在身份验证部分遇到问题。

I am running into a problem with the authentication part.

注意:记入 https://markheath.net/post/deploy-azure-webapp-kudu-zip-api 了解脚本想法。

Note: Credit to https://markheath.net/post/deploy-azure-webapp-kudu-zip-api for the script ideas.

下面是我的PowerShell脚本。

Below is my PowerShell script.

$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

运行此脚本时,我会得到

When I run this script I get

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.

我正在使用我为应用程序服务部署下载的* .PublishSettings文件中的userName和userPWD值Azure中的广告位设置。我可以在VS2017的发布向导中导入相同的* .PublishSettings文件,并将其成功发布到该插槽。我只是似乎无法在PowerShell中做到这一点。

I am using the userName and userPWD values from the *.PublishSettings file I downloaded for the app service deployment slot settings in Azure. I can import this same *.PublishSettings file in the publish wizard in VS2017 and successfully publish to that slot. I just can't seem to do it in PowerShell.

我在这里缺少什么?

推荐答案

这里的解决方案非常简单。我使用的是Microsoft从publishSettings文件生成的用户名,该用户名以$开头。因此,PowerShell删除了$和第一个字符。我给用户名加上了反勾号,这防止了用户名被剥夺。现在它可以正常工作。

The solution here was fairly simple. I was using the Microsoft generated username from the publishSettings file and that username started with a $. So, PowerShell was stripping the $and first characters. I prefixed the username with a back-tick and this prevented the username from being stripped. It is now working correctly.

我还在azurewebsites.net域之后添加了:443,因为那是它出现在publishSettings文件中的方式,但是我不确定由于网址已经以https://开头,因此实际上是必需的。

I also added the:443 after the azurewebsites.net domain since that is the way it appears in the publishSettings file, but I am not sure it is actually needed since the url starts with https:// already.

这篇关于如何从Bamboo部署服务器中使用Azure kudu zipdeploy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆