Auto configure 403 HTML page through azure pipelines for azure web app

Santhya 110 Reputation points
2024-03-18T13:13:25.05+00:00

Hi Team,

In azure app service I have restricted internet access and instead of platform error page I have added custom HTML file manually through configuration-->error pages-->configure HTML to 403 error code. . How can I deploy this file through azure devops pipeline along with my code so that it will be picked automatically to display for 403

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,839 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 15,696 Reputation points
    2024-03-21T04:40:17.47+00:00

    Hello @Santhya you can include the custom HTML file in your code repository and deploy it using Azure DevOps pipeline by following these steps:

    1. Add your custom HTML file for the 403 error page to your code repository. You might want to place it in a directory that’s included in your deployment, such as the root directory or a wwwroot subdirectory.
    2. In your Azure pipeline YAML file, add a task to copy the custom HTML file to the appropriate location in the Azure App Service during deployment. Here’s an example of how you might do this:
    - task: AzureRmWebAppDeployment@4
      inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: '<Azure-Subscription>'
        appType: 'webApp'
        WebAppName: '<Web-App-Name>'
        packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
        CustomStartCommand: 'echo Your command here'
        enableCustomDeployment: true
        DeploymentType: 'webDeploy'
        RemoveAdditionalFilesFlag: true
        AdditionalArguments: '-skip:objectName=filePath,absolutePath=403.html'
    

    In this example, the AdditionalArguments field is used to prevent the 403.html file from being deleted during deployment. Replace <Azure-Subscription> and <Web-App-Name> with your Azure subscription and web app name, respectively.

    1. In the Azure portal, navigate to your App Service and then to “Configuration” > “Path Mappings” > “Error Pages”. Here, you can configure the path to your custom HTML file for the 403 error code.

    Remember to commit and push these changes to your repository. The next time you run your pipeline, it should deploy the custom HTML file to your Azure App Service.

    Hope that helps.

    Best,

    Grace