Deploying automatically a static website into Azure using Bitbucket pipelines

Viewed 1331

I am new to azure and I want to deploy automatically a static website into an azure blob storage with bitbucket pipeline yml script. Can someone please mention the process that we need to follow?

2 Answers

I don't use BitBucket, but I publish my personal site to Azure blob storage with an Azure DevOps pipeline. You should be able to use a similar Azure Pipeline, but wire it up to your BitBucket repository instead of Azure Repos. Your tasks should look something like this:

steps:
- task: AzureFileCopy@2
  displayName: 'AzureBlob File Copy'
  inputs:
    SourcePath: .
    azureSubscription: <Your subscription here>
    Destination: AzureBlob
    storage: <storage account name>
    ContainerName: <Blob storage container here>

If you use CDN with your site, you might want to flush the CDN cache so updates become instantly visible:

steps:
- task: AzureCLI@1
  displayName: 'Purge the CDN cache'
  inputs:
    azureSubscription: '<Your subscription here>'
    scriptLocation: inlineScript
    inlineScript: 'az cdn endpoint purge --resource-group ''yevster.com'' --profile-name ''<CDN profile name>'' --name <name> --content-paths ''/'''

Quick update: it looks like this is what you're looking for if you want to do it in BitBucket. I haven't tried it. You'll also need to use the Azure CLI Run task to flush the CDN cache.

Related