I am porting a simple webpack based static client side application from GitLab to Azure DevOps. Following the build stage I need to deploy the contents of the dist
folder to an Azure ADLSg2 storage container that hosts the client side application.
The following partial shows the working deployment stage from the .gitlab-ci.yaml
that uses the Azure CLI:
prod-deploy-azure:
stage: deploy
image: mcr.microsoft.com/azure-cli
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
dependencies:
- 'prod-build'
before_script:
- 'az login --service-principal -u ${AZURE_SP_ID} -p ${AZURE_SP_SECRET} --tenant ${AZURE_TENANT}'
- 'STORAGE_KEY=`az storage account keys list --account-name ${AZURE_STORAGE_NAME_DEV} --output json --query "[0].value"`'
- 'az storage container create --auth-mode key --account-key ${STORAGE_KEY} --account-name ${AZURE_STORAGE_NAME_DEV} --name ${AZURE_STORAGE_CONTAINER} --public-access blob'
script: # Check that the dist directory exists from the build stage
- |
if [ -d 'dist' ] ; then
cd dist
pwd;
ls -latrR;
az storage blob upload-batch --auth-mode key --account-key ${STORAGE_KEY} --account-name ${AZURE_STORAGE_NAME_DEV} --overwrite true --source ${PWD} --destination ${AZURE_STORAGE_CONTAINER}
else
echo 'No dist directory abort deployment to ' ${AZURE_STORAGE_NAME_DEV} ${AZURE_STORAGE_CONTAINER}
fi;
However, despite some investigation on this site and MS knowledge sites I am unable to figure out how this might be done in ADO. Any pointers or assistace would be gratefully received.
Thanks to @Doug Deploy Static Angular App to Azure BLOB Storage
Full CICD YAML
variables:
- name: storageContainer
value: rtt2
- name: subscription
value: Rate Test Tool 2 (RTT2)
trigger:
branches:
include:
- main
stages:
- stage: __default
jobs:
- job: Job
pool:
vmImage: windows-latest
steps:
- task: UseNode@1
inputs:
version: '20.16.0'
force32bit: true
- task: CmdLine@2
displayName: npm install
inputs:
script: |
npm install
- task: CmdLine@2
displayName: npm run build
inputs:
script: |
npm run build
- task: AzureFileCopy@6
displayName: Deploy Rate Test Tool 2 (RTT2) to Storage Account
inputs:
SourcePath: '$(System.DefaultWorkingDirectory)\dist\*'
azureSubscription: $(subscription)
Destination: 'AzureBlob'
storage: $(storageContainer)
ContainerName: '$web'
BlobPrefix: ''
- task: AzureCLI@2
displayName: Delete Old Files
inputs:
azureSubscription: $(subscription)
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: 'az storage blob delete-batch -s `$web --account-name $(storageContainer) --if-unmodified-since $(Get-Date ((Get-Date).addMinutes(-5)) -UFORMAT +%Y-%m-%dT%H:%MZ)'