# Starter pipeline # Start with a minimal pipeline that you can customize to build and deploy your code. # Add steps that build, run tests, deploy, and more: # https://aka.ms/yaml trigger: - master pool: vmImage: 'ubuntu-latest' steps: - script: | az login --service-principal -u $(client-id) -p $(client-secret) --tenant $(tenant-id) end=`date -u -d "30 minutes" '+%Y-%m-%dT%H:%M:%SZ'` TARGET_SAS_TOKEN=$(az storage account generate-sas --permissions clrwapud --account-name $(storage-account) --services bfqt --resource-types sco --expiry $end -o tsv) wget https://aka.ms/downloadazcopy-v10-linux -O azcopy.tar.gz && tar -C /tmp -xvzf azcopy.tar.gz /tmp/azcopy_linux_*/azcopy copy "$(blob-sas-uri)" "$TARGET_BLOB_URI?$TARGET_SAS_TOKEN" displayName: 'Setting up VHD availability from PROD Subscription to TEST (Optional)' enabled: true - script: | echo "Setting up Terraform" cd azure/ terraform init displayName: 'Setup Terraform environment' - script: | cd azure/ terraform plan terraform apply -auto-approve env: TF_VAR_image_name: $(image-name) TF_VAR_blob_uri: $(target_blob_uri) TF_VAR_file_uris: $(file-uris) TF_VAR_vhd_name: $(vhd-name) TF_VAR_testing_rg: image-testing-$(Agent.Id) ARM_CLIENT_ID: $(client-id) ARM_CLIENT_SECRET: $(client-secret) ARM_SUBSCRIPTION_ID: $(subscription-id) ARM_TENANT_ID: $(tenant-id) displayName: 'Deploy Azure Resources with Terraform' - script: | cd azure/ terraform destroy -auto-approve env: TF_VAR_image_name: $(image-name) TF_VAR_blob_uri: $(target_blob_uri) TF_VAR_file_uris: $(file-uris) TF_VAR_vhd_name: $(vhd-name) TF_VAR_testing_rg: image-testing-$(Agent.Id) ARM_CLIENT_ID: $(client-id) ARM_CLIENT_SECRET: $(client-secret) ARM_SUBSCRIPTION_ID: $(subscription-id) ARM_TENANT_ID: $(tenant-id) displayName: 'Destroy Azure Resources with Terraform' enabled: true condition: always()