0

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?

rjzii
  • 14,236
  • 12
  • 79
  • 119
  • One piece of information that may or may not be relevant is that I have two subscriptions associated with my account due to my role on multiple projects. As near as I can tell though, this should not impact deployments if they are properly configured. – rjzii Mar 04 '16 at 15:47

3 Answers3

2

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.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • That was one of the first things we tried actually. Right now both the web app and the deployment slot are set to VS 2013 and debugging off. – rjzii Mar 04 '16 at 16:17
  • Yep, it was a long shot. You must be hitting a separate condition. – David Ebbo Mar 04 '16 at 20:21
  • I have remote debugging turned off, which is the default setting. I have a BASIC App Service instance, so no Slots. But I cannot get past this issue. Is there a way to define the powershell script VSTO uses? I have tried with several projects now. New site, new projects. Even a file new project with just the bare minimum API controller setup. Everything fails at this step. – Chris Love Apr 04 '16 at 12:27
  • Check out the links down below. The full process that worked for me was setting the debug version to an earlier vs version and then turning the remote debugging off: http://stackoverflow.com/a/35852636/92364 – AllenSanborn Apr 14 '16 at 15:55
1

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.

Community
  • 1
  • 1
rjzii
  • 14,236
  • 12
  • 79
  • 119
0

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?

enter image description here

bmoore-msft
  • 8,376
  • 20
  • 22
  • Since this is hosted VSTS I have no control over the Powershell scripts that are being run by the deployment wizard - which are the same ones that are provided as part of the Azure Web App Deployment process. As I noted before though, deployments from Visual Studio 2015 are fine and generally my expectations are that VSTS should work more or less the same as VS2015. – rjzii Mar 06 '16 at 21:40
  • Can you clarify - how are you getting the output from your OP? – bmoore-msft Mar 07 '16 at 15:33