patternMinor
Azure Pipelines: Exclude folders using Azure App Service Deploy
Viewed 0 times
pipelinesappfoldersdeployazureserviceusingexclude
Problem
I have an Azure DevOps Pipeline which includes an Azure App Service Deploy task (
The Azure App Service destination, however, contains files in several pre-established folders which are managed independent of the continuous delivery process. We would like to use the Remove additional files at destination flag (
Disclaimer: I don't consider this a best practice and, in the future, we will be moving these files off to a separate storage location. Until then, I'd like to find a solution that will work resolve this.
In Visual Studio 2019, we achieve this by excluding those files from our publishing process using the
This approach works well for Visual Studio. Those rules do not appear to be honored by the
Is there a way to honor the
AzureRmWebAppDeployment) for deploying an ASP.NET Core 3.1 project:- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'Azure Subscription(01234567-89ab-cdef-0123-456789abcdef)'
appType: 'webApp'
WebAppName: 'MyStagingSite'
packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
enableCustomDeployment: true
DeploymentType: 'webDeploy'
enableXmlTransform: false
enableXmlVariableSubstitution: true
RemoveAdditionalFilesFlag: falseThe Azure App Service destination, however, contains files in several pre-established folders which are managed independent of the continuous delivery process. We would like to use the Remove additional files at destination flag (
RemoveAdditionalFilesFlag) while leaving those folders intact.Disclaimer: I don't consider this a best practice and, in the future, we will be moving these files off to a separate storage location. Until then, I'd like to find a solution that will work resolve this.
In Visual Studio 2019, we achieve this by excluding those files from our publishing process using the
MsDeploySkipRules in our csproj file:
…
dirPath
wwwroot\\Uploads
This approach works well for Visual Studio. Those rules do not appear to be honored by the
AzureRmWebAppDeployment task, however, even when using the "Web Deploy" deployment method (DeploymentType).Is there a way to honor the
MsDeploySkipRules when using the AzureRmWebAppDeployment task? If not, if there a way to provide a list of folders which should be skipped or ignored as part of the deployment process? Or, alternatively, if there another task that will permit one of these options?Solution
As @yang-shen-msft notes on Stack Overflow, there doesn't appear to be a way to honor the
Since there doesn't appear to be any official documentation for the
First, it's useful to recognize that when you deploy a project via Visual Studio, it's simply taking the
The
Translating this to the Azure App Service Deploy (
Note: Multiple
Unfortunately, as mentioned above, there doesn't appear to be any official, first-party documentation for the
MSDeploySkipRules defined in the csproj file. Instead, files and folders can be skipped by defining the Additional Arguments (AdditionalArguments) parameter of the Azure App Service Deploy (AzureRmWebAppDeployment) task, as discussed in another Stack Overflow answer.Since there doesn't appear to be any official documentation for the
-skip rules, and the MSDeploy.exe documentation that Azure Pipelines references is out-of-date, the following provides additional details.First, it's useful to recognize that when you deploy a project via Visual Studio, it's simply taking the
MSDeploySkipRules configured in the csproj file and adding them to it's internal call of msdeploy.exe as -skip rules. So, given the following rule defined in the csproj:
…
dirPath
wwwroot\\Uploads
The
-skip rule is interpreted as:msdeploy.exe -skip:objectName=dirPath,absolutePath=wwwroot\\UploadsTranslating this to the Azure App Service Deploy (
AzureRmWebAppDeployment) task, the resulting yml might look like:- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'Azure Subscription'
appType: 'webApp'
WebAppName: 'MyStagingSite'
packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
enableCustomDeployment: true
DeploymentType: 'webDeploy'
enableXmlTransform: false
enableXmlVariableSubstitution: true
RemoveAdditionalFilesFlag: true
AdditionalArguments: '-skip:objectName=dirPath,absolutePath=wwwroot\\Uploads'Note: Multiple
-skip rules can be defined on the same msdeploy.exe call.Unfortunately, as mentioned above, there doesn't appear to be any official, first-party documentation for the
-skip rules on msdeploy.exe. The 2014 documentation acknowledges them, and provides two examples, but doesn't expand on the options. That said, way back in 2012, @richard-szalay wrote a useful article, "Demystifying MSDeploy skip rules", which provides useful direction here for anyone requiring additional control over their -skip rules.Code Snippets
msdeploy.exe -skip:objectName=dirPath,absolutePath=wwwroot\\Uploads- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'Azure Subscription'
appType: 'webApp'
WebAppName: 'MyStagingSite'
packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
enableCustomDeployment: true
DeploymentType: 'webDeploy'
enableXmlTransform: false
enableXmlVariableSubstitution: true
RemoveAdditionalFilesFlag: true
AdditionalArguments: '-skip:objectName=dirPath,absolutePath=wwwroot\\Uploads'Context
StackExchange DevOps Q#10923, answer score: 3
Revisions (0)
No revisions yet.