I am building a pipeline for deploying my application, the first thing I needed to do was deploy my Azure resources.
I have a tendency to be more imperative with my deployment strategy, using Azure PowerShell and Azure CLI over Azure Resource Management (ARM) templates.
I use Visual Studio Code to code my azure-pipelines.yml
file, Azure Powershell, *.ps1
, and Azure CLI, *.azcli
files.
I use the .azcli
file extension for the Visual Studio Code integration.
It seems though that the AzureCLI@2 task only wants to run files with an extension of .sh
.
Fully qualified path of the script(.ps1 or .bat or .cmd when using Windows-based agent else .ps1 or .sh when using linux-based agent) or a path relative to the default working directory
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-cli?view=azure-devops
Assuming my findings are correct, I think I am going to have to duplicate my .azcli
files and assign the .sh
extension.
I have a file called CreateResourceGroups.azcli
that contains the following script:
1 |
az group create -n YOUR_RESOURCE_GROUP_NAME -l "YOUR_LOCATION" |
I created another file, called CreateBashScripts.ps1
, that contains the following:
1 |
Copy-Item -Path CreateResourceGroups.azcli -Destination CreateResourceGroups.sh |
And then in my azure-pipelines.yml
I have the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
stages: - stage: ProvisionAzureResources jobs: - job: ProvisionAzureResources steps: - task: AzurePowerShell@5 displayName: CreateBashFiles inputs: azureSubscription: 'YOUR_AZURE_SUBSCRIPTION_NAME' ScriptType: 'FilePath' ScriptPath: './CreateBashFiles.ps1' azurePowerShellVersion: 'LatestVersion' - task: AzureCLI@2 displayName: CreateResourceGroups inputs: azureSubscription: 'azure.com_mattruma' scriptType: 'bash' scriptLocation: 'scriptPath' scriptPath: 'CreateResourceGroups.sh' |
That seems to do the trick!
Now I get all the VS Code support for .azcli
files and simply copy and rename them so Azure DevOps can run them.
If there is a better way, or I am totally missing something, please share!
Discover more from Matt Ruma
Subscribe to get the latest posts sent to your email.