Adventures with Azure DevOps: .azcli Files to .sh

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

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:


I created another file, called CreateBashScripts.ps1, that contains the following:

Copy-Item -Path CreateResourceGroups.azcli -Destination

And then in my azure-pipelines.yml I have the following:

  - stage: ProvisionAzureResources
      - job: ProvisionAzureResources
        - task: AzurePowerShell@5
          displayName: CreateBashFiles
            azureSubscription: 'YOUR_AZURE_SUBSCRIPTION_NAME'
            ScriptType: 'FilePath'
            ScriptPath: './CreateBashFiles.ps1'
            azurePowerShellVersion: 'LatestVersion'
        - task: AzureCLI@2
          displayName: CreateResourceGroups
            azureSubscription: 'azure.com_mattruma'
            scriptType: 'bash'
            scriptLocation: 'scriptPath'
            scriptPath: ''

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!

Leave a Reply

Your email address will not be published.