Search code examples
azuredeploymentweb-configmsdeploywebdeploy

Web Deploy Set Parameter using external file


We have an Website project that's hosted in Azure, and we use Web.config transforms for setting environment variables. However, our current approach for building the system for different environments is to build the project multiple times (currently this is 3), which is inefficient.

We'd like to move to using Web Deploy, as this would then set us up nicely for using Release Manager.

Our issue is around using Web Deploy parameters instead of web.config transforms; we need to substitute multiple xml elements, rather than single values.

After much research, I found these 2 articles which detail almost exactly what I'm trying to do http://blogs.iis.net/elliotth/web-deploy-xml-file-parameterization http://www.iis.net/learn/publish/using-web-deploy/parameterization-improvements-in-web-deploy-v3

Essentially I'm trying to replicate Scenario 5, but using a separate Set Parameter file for the value.

Unfortunately, in the examples, referencing an external xml file only works if it is on the target machine. Some testing with a colleague confirmed this; works on local machine, but not on Azure.

Is there a way I can force Web Deploy to look in a particular location for the external configuration files?


Solution

  • As you've already noticed, Web Deploy is only able to read replacement values on the local machine or on a UNC share. It can't read that specific file over HTTP.

    If you're deploying to an Azure Web App, then one thing you could try would be to use Kudu/FTP to manually upload that file one level above your wwwroot folder. Then you could specify the file location like so:

    D:\home\site\prices.xml:://book[@name='book1']/price

    Of course this implies that you'd have to pre-upload this file before publishing to your site, so it's not a perfect solution, but it should work for what you're trying to accomplish.