简体   繁体   中英

Visual Studio Team Services Azure Deployment task fails to deploy web app

We recently stood up a new Azure account and are in the process of developing a new application to be deployed to it as a web app. While we are able to deploy to our staging slot from Visual Studio 2015, when attempting to deploy an automated build from Visual Studio Team Services (hosted by Microsoft) we are getting the following error:

Get-AzureWebSite -Name $APPLICATION -ErrorAction SilentlyContinue -ErrorVariable azureWebSiteError -Slot staging
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.WindowsAzure.Commands.Websites.GetAzureWebsiteCommand.Do(Action call) in d:\workspace\powershell-publish\src\ServiceManagement\Services\Commands\Websites\GetAzureWebSite.cs:line 138
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzureSMCmdlet.ProcessRecord() in d:\workspace\powershell-publish\src\ServiceManagement\Common\Commands.ServiceManagement.Common\AzureSMCmdlet.cs:line 174
New-AzureWebSite -Name $APPLICATION -Location North Central US -Slot staging
Conflict: Website with given name $APPLICATION already exists.
Publish-AzureWebsiteProject -Name "$APPLICATION" -Package "C:\a\1\a\$APPLICATION.zip" -Slot "staging"  -ErrorVariable publishAzureWebsiteError
The website $APPLICATION was not found. Please specify a valid website name.
Cannot get website, deployment status is not updated

This is a fairly significant issue since it is preventing us from using continuous deployment at this time. Are there any work around or configuration settings that we should look at to fix this?

There is a known issue that causes publishing from VSTS to fail if the Web App has VS 2015 Debugging enabled. Can you check whether it is the case for you, and try again after turning off debugging in the Azure portal?

That issue will be fixed soon, so treat this as a temporary workaround.

This was eventually traced back to two problems.

The first problem was that we needed to load up a different management certificate since the one we were using was defaulting to a different account. This goes back to the issue of having one account associated with more than one subscription. At the time of this writing, there doesn't appear to be a way of specifying which subscription to download .

The second problem appears to have been associated with the known bug mentioned by David Ebbo in their answer .

A couple things you can try:

  • Since you mentioned you have 2 subscriptions, make sure that script you have above is running against the correct subscription, if it's not, it would give the exact error you're seeing. Put a:

    Get-AzureSubscription -Current

command at the top of your script and see if that's what you'd expect.

  • VSTS has a build task for deploying to a web app, can you deploy the package using that task?

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM