Search code examples
azurevisual-studio-2013msbuildazure-deployment

Azure worker role gets published with the wrong service configuration


I'm trying to get the "publish to azure" functionality in VS2013 going for my worker-role cloud-service project.

The problem I'm having is that no matter what I change the service configuration settings to the application is always deployed with the Localservice configuration

My .azurePubxml:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <PropertyGroup>
    <AzureCredentials>{"ServiceManagementEndpoint":"https:\/\/management.core.windows.net\/","SubscriptionId":"redacted"}</AzureCredentials>
    <AzureDeleteDeploymentOnFailure>False</AzureDeleteDeploymentOnFailure>
    <AzureDeploymentLabel>MyWorkerRole</AzureDeploymentLabel>
    <AzureDeploymentReplacementMethod>AutomaticUpgrade</AzureDeploymentReplacementMethod>
    <AzureSlot>Staging</AzureSlot>
    <AzureEnableRemoteDesktop>True</AzureEnableRemoteDesktop>
    <AzureEnableWebDeploy>False</AzureEnableWebDeploy>
    <AzureFallbackToDeleteAndRecreateIfUpgradeFails>False</AzureFallbackToDeleteAndRecreateIfUpgradeFails>
    <AzureHostedServiceLabel>MyLabel</AzureHostedServiceLabel>
    <AzureHostedServiceName>MyService</AzureHostedServiceName>
    <AzureEnableIntelliTrace>False</AzureEnableIntelliTrace>
    <AzureEnableProfiling>False</AzureEnableProfiling>
    <AzureServiceConfiguration>Staging</AzureServiceConfiguration>
    <AzureSolutionConfiguration>Staging</AzureSolutionConfiguration>
    <AzureStorageAccountLabel>webstorage</AzureStorageAccountLabel>
    <AzureStorageAccountName>webstorage</AzureStorageAccountName>
    <AzureAppendTimestampToDeploymentLabel>True</AzureAppendTimestampToDeploymentLabel>
  </PropertyGroup>
</Project>

As you can see, the AzureServiceConfiguration is set to Staging. If i look at the output from the build I can see these lines:

Target "ResolveServiceConfiguration" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Windows Azure Tools\2.6\Microsoft.WindowsAzure.targets" from project "path-to.ccproj" (target "CoreResolveServiceModel" depends on it):
3>  Task "Message"
3>      Target Profile: Local
3>  Task "Message"
3>      Service Configurations: ServiceConfiguration.Staging.cscfg;ServiceConfiguration.Production.cscfg;ServiceConfiguration.Local.cscfg
3>  Task "Message"
3>      Looking for a service configuration file named: ServiceConfiguration.Local.cscfg
3>  Task "FindInList"
3>  Task "Message"
3>      Source Service Configuration: ServiceConfiguration.Local.cscfg
3>  Task "Message"
3>      Target Service Configuration: bin\Staging\ServiceConfiguration.cscfg

The end-result is that the ServiceConfiguration.Local.cscfg is used in the deployment instead of ServiceConfiguration.Staging.cscfg.

What does work though is to change the Service Configuration setting to staging under Development->Run/debug. enter image description here

But this setting controls which configuration file is used when I run the app locally, so naturally I don't want to mess with it.

Also, if I use the Project->Package... option and choose staging I get the correct package and the correct config file generated. I've also tried bulding manually with msbuild from commandline, works great as well.

Tried updating to azure sdk 2.6 in hopes that it would solve it, but no difference.

Should also say that I have this working in my web-role project. But for external reasons I had to split the worker-role to its own cloud project.

Update Some more info, I took a another closer look at the build log and found this:

 1>------ Build started: Project: MyProject, Configuration: Debug Any CPU ------
1>Build started 6/5/2015 5:15:03 PM.
1>Building with tools version "12.0".
1>Target "_CheckForInvalidConfigurationAndPlatform" in file "C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets" from project "path_to_project.csproj" (entry point):
1>Task "Error" skipped, due to false condition; ( '$(_InvalidConfigurationError)' == 'true' ) was evaluated as ( '' == 'true' ).
1>Task "Warning" skipped, due to false condition; ( '$(_InvalidConfigurationWarning)' == 'true' ) was evaluated as ( '' == 'true' ).
1>Using "Message" task from assembly "Microsoft.Build.Tasks.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>Task "Message"
1>  Task Parameter:Text=Configuration=Debug
1>  Task Parameter:Importance=Low
1>  Configuration=Debug

So it seems that neither

<AzureServiceConfiguration>Staging</AzureServiceConfiguration>
<AzureSolutionConfiguration>Staging</AzureSolutionConfiguration>

from the .azurePubxml are actually being used as input to the build script.

It all seems to boil down to, where is the Publish to Azure function pulling its parameters from, if not from the .azurePubxml file?


Solution

  • Never got this working fully in VS2013 but now I've gone up to VS2015 and publish to Azure works as expected again.