从 github 部署到 Azure 后自动使用密码编辑配置文件

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

我在 Azure 上有一个 asp.net Web 应用程序,并从 GitHub 持续集成。效果很好,我已经设法将大部分密码和连接字符串从源代码中移到应用程序设置中。但是,有一个文件我无法设法解决如何在源代码中没有它的情况下提供连接字符串。文件 FileSystemProviders.config 看起来像:

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

有没有办法在每次部署后制作一个脚本 运行 自动用我的连接字符串替换 **SECRET1**?或者其他方式?

我找到了一个解决方案,将其发布以防有人对此有疑问。 Kudu 服务有一些 post deployment action hooks。因此,在 "D:\home\site\deployments\tools\" 中创建一个名为 "PostDeploymentActions" 的新目录后,我将两个文件放入目录中,然后脚本将连接字符串复制到正确的位置。

  1. CopyFiles.bat

    copy D:\home\site\deployments\tools\PostDeploymentActions\HiddenFileSystemProviders.config D:\home\site\wwwroot\Config\FileSystemProviders.config
    
  2. HiddenFileSystemProviders.config 是我的配置文件和我的私有连接字符串。

脚本在每次从 GitHub 部署到 Azure 后运行。