'Deploy an Azure Web App' step type incorrectly assumes web app names are globally unique

Hello,

When an Azure account/subscription has more than 1 web app with the same name, the ‘Deploy to Azure’ step type does not properly distinguish between them.

Web apps that exist in App Service Environments (https://azure.microsoft.com/en-us/documentation/articles/app-service-app-service-environment-intro/) can share a name with webapps that exist in the public environment. When this happens, Calamari may download the wrong publish profile, because it scans each resource group until it finds the first site that matches the provided name (https://github.com/OctopusDeploy/Calamari/blob/19361500800e442f27a997532dde5b5ce294ddc5/source/Calamari.Azure/Integration/Websites/Publishing/ResourceManagerPublishProfileProvider.cs#L27-L28).

For example, let’s say I have an App Service Environment named ‘my-ase’. I can create a webapp named ‘my-webapp’ in the ASE (which will be hosted at my-webapp.my-ase.p.azurewebsites.net) and a second webapp named ‘my-webapp’ in the public environment (which will be hosted at my-webapp.azurewebsites.net). In the Octopus UI, both webapps will be shown in the “Web App” dropdown, but when I deploy, Octopus will deploy to the site in the first resource group alphabetically regardless of which one I chose.

To globally identify a webapp, you need its name AND its resource group. (Azure won’t let you have two webapps with the same name in a single resource group, no matter what App Service Environment shenanigans you’re using.)

Hi,

Thanks for reporting this! I have created an issue that you can track here: https://github.com/OctopusDeploy/Issues/issues/2554
I am not sure how soon this can be completed, but if possible the workaround would be to create a new Web App.

Vanessa

I think this might still be an issue.

I am using v3.4.9 and having issues with deploying Web Apps. I suspect Octopus is retrieving the Publish Profiles from the wrong Resource Group.

I have 5 Resource Groups, one for each of our test environments and they are distinguishable by the number 1 to 5. Each resource group has a Web App and for consistency, the Web Apps have the same name.
After studying the deployment log, I can see that it has retrieved the publish profile for Test1, instead of the publish profile for Test3.

Deployment log


Deploying to Azure WebApp ‘WebApp(Staging)’ in Resource Group WebApp-Test3, using subscription-id '### SubscriptionId ###'
September 19th 2016 12:45:00Verbose
Retrieving publishing profile…
September 19th 2016 12:45:01Verbose
Retrieved publishing profile: URI: app-staging.scm.ase-test1.p.azurewebsites.net:443 UserName: $WebApp__Staging
September 19th 2016 12:45:01Verbose
Using ID ‘c6701672-0833-4e32-972a-f43d615fbe81’ for connections to the remote server.
September 19th 2016 12:45:01Verbose
Pre-authenticating to remote agent URL ‘https://app-staging.scm.ase-test1.p.azurewebsites.net/msdeploy.axd?site=WebApp(Staging)’ as ‘$WebApp__Staging’.
September 19th 2016 12:45:01Error
Microsoft.Web.Deployment.DeploymentAgentUnavailableException: Could not complete the request to remote agent URL ‘https://app-staging.scm.ase-test1.p.azurewebsites.net/msdeploy.axd?site=WebApp(Staging)’. —> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. —> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. —> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
September 19th 2016 12:45:01Error
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
September 19th 2016 12:45:01Error
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
September 19th 2016 12:45:01Error
— End of inner exception stack trace —
September 19th 2016 12:45:01Error
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
September 19th 2016 12:45:01Error
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
September 19th 2016 12:45:01Error
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
September 19th 2016 12:45:01Error
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
September 19th 2016 12:45:01Error
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
September 19th 2016 12:45:01Error
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
September 19th 2016 12:45:01Error
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
September 19th 2016 12:45:01Error
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
September 19th 2016 12:45:01Error
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
September 19th 2016 12:45:01Error
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
September 19th 2016 12:45:01Error
at System.Net.ConnectStream.WriteHeaders(Boolean async)
September 19th 2016 12:45:01Error
— End of inner exception stack trace —
September 19th 2016 12:45:01Error
at System.Net.HttpWebRequest.GetResponse()
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponseHelper(HttpWebRequest request)
September 19th 2016 12:45:01Error
— End of inner exception stack trace —
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponseHelper(HttpWebRequest request)
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponse(HttpWebRequest request)
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.AgentClientProvider.PerformHeadRequestHelper(Boolean getVersionInfo, Version& maximumSupportedVersion, Version& minimumSupportedVersion)
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.AgentClientProvider…ctor(DeploymentProviderContext providerContext, DeploymentBaseContext baseContext, String serverVersion)
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.DeploymentManager.CreateObjectPrivate(DeploymentProviderContext providerContext, DeploymentBaseOptions baseOptions, DeploymentObject sourceObject, String serverVersion)
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.DeploymentManager.CreateDestinationObject(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentObject sourceObject, String serverVersion)
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)
September 19th 2016 12:45:01Error
at Calamari.Azure.Deployment.Conventions.AzureWebAppConvention.Install(RunningDeployment deployment) in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Deployment\Conventions\AzureWebAppConvention.cs:line 18
September 19th 2016 12:45:01Error
at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
September 19th 2016 12:45:01Error
at Calamari.Deployment.ConventionProcessor.RunConventions() in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 28
September 19th 2016 12:45:01Error
Running rollback conventions…
September 19th 2016 12:45:01Error
Microsoft.Web.Deployment.DeploymentAgentUnavailableException: Could not complete the request to remote agent URL ‘https://app-staging.scm.ase-test1.p.azurewebsites.net/msdeploy.axd?site=WebApp(Staging)’. —> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. —> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. —> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
September 19th 2016 12:45:01Error
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
September 19th 2016 12:45:01Error
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
September 19th 2016 12:45:01Error
— End of inner exception stack trace —
September 19th 2016 12:45:01Error
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
September 19th 2016 12:45:01Error
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
September 19th 2016 12:45:01Error
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
September 19th 2016 12:45:01Error
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
September 19th 2016 12:45:01Error
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
September 19th 2016 12:45:01Error
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
September 19th 2016 12:45:01Error
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
September 19th 2016 12:45:01Error
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
September 19th 2016 12:45:01Error
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
September 19th 2016 12:45:01Error
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
September 19th 2016 12:45:01Error
at System.Net.ConnectStream.WriteHeaders(Boolean async)
September 19th 2016 12:45:01Error
— End of inner exception stack trace —
September 19th 2016 12:45:01Error
at System.Net.HttpWebRequest.GetResponse()
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponseHelper(HttpWebRequest request)
September 19th 2016 12:45:01Error
— End of inner exception stack trace —
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponseHelper(HttpWebRequest request)
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponse(HttpWebRequest request)
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.AgentClientProvider.PerformHeadRequestHelper(Boolean getVersionInfo, Version& maximumSupportedVersion, Version& minimumSupportedVersion)
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.AgentClientProvider…ctor(DeploymentProviderContext providerContext, DeploymentBaseContext baseContext, String serverVersion)
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.DeploymentManager.CreateObjectPrivate(DeploymentProviderContext providerContext, DeploymentBaseOptions baseOptions, DeploymentObject sourceObject, String serverVersion)
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.DeploymentManager.CreateDestinationObject(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentObject sourceObject, String serverVersion)
September 19th 2016 12:45:01Error
at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)
September 19th 2016 12:45:01Error
at Calamari.Azure.Deployment.Conventions.AzureWebAppConvention.Install(RunningDeployment deployment) in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Deployment\Conventions\AzureWebAppConvention.cs:line 18
September 19th 2016 12:45:01Error
at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
September 19th 2016 12:45:01Error
at Calamari.Deployment.ConventionProcessor.RunConventions() in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 50
September 19th 2016 12:45:01Error
at Calamari.Azure.Commands.DeployAzureWebCommand.Execute(String[] commandLineArguments) in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Commands\DeployAzureWebCommand.cs:line 86
September 19th 2016 12:45:01Error
at Calamari.Program.Execute(String[] args) in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari\Program.cs:line 38
September 19th 2016 12:45:02Fatal
The remote script failed with exit code 100

Hi @B Richardson,

Could you please provide a full deployment log with these variable expansion variables turned on: http://docs.octopus.com/display/OD/Debug+problems+with+Octopus+variables
You can make the thread private (though it will share with the others, create your own private thread or email it through to support @ octopus dot com)

Vanessa

Hi Vanessa,

I have sent this via e-mail. However, after manually creating a Staging deployment slot, the correct Publish Profile now seems to be retrieved. The deployment does still fail with the same “Microsoft.Web.Deployment.DeploymentAgentUnavailableException: Could not complete the request to remote agent URL” error.

Thanks,

Brian

Hi Brian,

Thanks for the logs. We (me and a dev) had a look at the logs, and with your above comments I guess we ended up quite confused. In the end it did look like it was a problem with not being able to create the slot - and not with the incorrect web app. We have confirmed this is working when we attempted to do the same.

What was different in our testing was we did not also use the resource group APIs and we wondered if maybe that was causing the conflict or problem.

It would help to get another update on what is (and isn’t) working and a set of logs to match. It might be that we are a bit confused from the original reported issue. Sorry.

Vanessa

Hi Vanessa,

In this scenario, I was attempting to deploy to an App Service Environment. I suspect this was the cause of the issue. I was attempting to create an App Service deployment slot via PowerShell, before using a Deploying by Azure Web App step, and did have some issues with doing correctly. This process works fine when the App Services and Resource Groups are not used with an App Service Environment.

I think the most significant barrier I experienced with this approach is with the Login-AzureRmAccount error and trying to overcome it.

Fortunately, I no longer needed to progress with using ASE’s and could continue working with standalone App Services instead. If this had not been the case, I might still have been stuck with overcoming the Login-AzureRmAccount error.

Notice:

This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.