Last active
August 11, 2022 03:12
-
-
Save jyotsnaravikumar/c9b8d3dd123c98273729ecc89c01fb7c to your computer and use it in GitHub Desktop.
Revisions
-
jyotsnaravikumar renamed this gist
Sep 29, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jyotsnaravikumar created this gist
Sep 29, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,74 @@ ## Programmatically Purging Azure Frontdoor CDN With AzDevops 1. Create a Azure Service Connection by creating a service principal so that devops process has access to perform pruging operation on frontdoor resource 1. Create a App Registration -> as spn-devops-dev 2. Goto Certificates and Secrets -> Add secret , note the ApplicationId and Secret 3. Goto Frontdoor instance -> open Access Control (IAM) -> Add Role Assignment -> Role as "Contributor" -> Assign Access To-> "user, groups or service principal" -> Select -> search for service principal spn-devops-dev -> Select 4. Note the Azure Service Connection name - as mymap-dev-service-connection 2. Add environment variables for Azure FrontDoor, ResourceGroup and Service Connection 3. Add a purging step which depends on the successly deploy. This ensure the cdn cache is refreshed with newer contents from the build after every build. ```yaml trigger: branches: include: - develop pool: mymap-agent-pool-01 variables: - group: viz-variables-develop schedules: - cron: "0 0 * * *" displayName: Daily midnight build - develop branches: include: - develop always: true stages: - stage: package_build jobs: - template: azure-pipelines/templates/build-template.yml parameters: map_subscription_key: $(NEXT_PUBLIC_AZURE_MAP_SUBSCRIPTION_KEY) appinsights_instrumentation_key: $(NEXT_PUBLIC_APPINSIGHTS_INSTRUMENTATIONKEY) build_id: $(Build.BuildId) - stage: deploy dependsOn: package_build jobs: - template: azure-pipelines/templates/deploy-template.yml parameters: app_name: "mymap-dev" azure_service_connection: 'mymap-dev - Azure-PublishProfile' - stage: purge dependsOn: deploy jobs: - template: azure-pipelines/templates/purge-template.yml parameters: front_door: $(AZURE_FRONTDOOR) resource_group: $(AZURE_RESOURCE_GROUP) azure_service_connection: 'mymap-dev-service-connection' ``` purge-template.yml ```yaml jobs: - job: purge pool: vmImage: ubuntu-16.04 steps: - task: AzureCLI@2 inputs: azureSubscription: ${{ parameters.azure_service_connection }} scriptType: 'bash' scriptLocation: 'inlineScript' inlineScript: | az extension add --name front-door az network front-door purge-endpoint --resource-group ${{ parameters.resource_group}} --name ${{ parameters.front_door}} --content-paths "/" ```