Ted Nyberg
Ted Nyberg

Reputation: 7391

Specify which config transform to use for continuous deployment to Azure web app

Is there a way to specify which config transform should be applied when deploying to an Azure web app through continuous integration (i.e. not through Publish in Visual Studio)?

We have continuous integration set up with Github, but it seems the Web.Release.config transform is always applied on deployment.

We would prefer to have a custom transform name, e.g. Web.Azure.config.

Is deployment slots used for this? And if so, is that the only way to do it?

Thanks!

PS. Does this question belong on ServerFault? I think it's more related to programming? DS.

Upvotes: 3

Views: 1586

Answers (2)

Ted Nyberg
Ted Nyberg

Reputation: 7391

The environment name can be set for a specific Azure web app by adding an application setting, in the Azure portal, called SCM_BUILD_ARGS with a value of -p:Environment MyAzureSite

This will set the environment name, resulting in a config transform named Web.MyAzureSite.config to be applied during build.

More information here

Upvotes: 5

Brian Sherwin
Brian Sherwin

Reputation: 962

The first thing you might consider is whether that configuration setting is appropriate for the web.config file whether it might be better managed in the Web App configuration inside of Azure. Any AppSettings managed in the portal will override anything in the web.config file.

See here for guidance: https://github.com/projectkudu/kudu/wiki/Managing-settings-and-secrets

However, to answer your question, the Azure Continuous Deploy uses the Kudu build process. The msbuild command that is passed to build your project on azure (after you git push/github pull) is something like:

MSBuild MyWebApp\MyWebApp.csproj /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TARGET%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Debug;SolutionDir="%DEPLOYMENT_SOURCE%"

This step does web.config transformation too. To customize deployment like the way you would like you might want to also take a look at:

https://github.com/projectkudu/kudu/wiki/Deployment-hooks

Upvotes: 2

Related Questions