Search code examples
asp.netazurecontinuous-integrationumbraco

Automatic edit a config file with password after deployment from github to azure


I have a asp.net web application on Azure, with continous integration from GitHub. Works good, and I have managed to move most of the passwords and connectionstrings off the source and into application settings. However there is one file I cannot manage to solve how to provide a connectionstring without having it in source. The file FileSystemProviders.config looks like:

 <Provider alias="media" type="Our.Umbraco.FileSystemProviders.Azure.AzureBlobFileSystem, Our.Umbraco.FileSystemProviders.Azure">
   <Parameters>
     <add key="connectionString" value="**SECRET1**"/>

Is there anyway to make a script running after each deployment that replaces **SECRET1** with my connectionstring automatically? Or any other way around?


Solution

  • I found a solution for this, posting it in case anyone wondering about the same. The Kudu service has some post deployment action hooks. So after creating a new directory in "D:\home\site\deployments\tools\" named "PostDeploymentActions", I put the two files into the directory, and the script copies the connectionstrings into right place.

    1. CopyFiles.bat

      copy D:\home\site\deployments\tools\PostDeploymentActions\HiddenFileSystemProviders.config D:\home\site\wwwroot\Config\FileSystemProviders.config
      
    2. HiddenFileSystemProviders.config is my config file with my private connectionstring.

    The scripts runs after each deployment from GitHub to Azure.