Hello!

We’ve been using the npm package to build the ADF source code. The npm package, which is officially from Microsoft, will generate an ARM tempalte, which can then be deployed. As we’re using Azure DevOps it makes sense to use the AzureResourceManagerTemplateDeployment@3 task to deploy the ARM Template.

All very nice, but we have found that owing to the sheer number of objects being deployed we get a very unhelpful error message back when it fails:

sad error time

This is helpful to exactly no one, and so this means that, assumming someone even knows where to look, they have to go and search the deployments registry for that resource group. And even if they do know where to look, then they may not have the correct permissions.

At this pointwe can either chalk it up to an annoyance and move on, or we can attempt to return the error messages. And this 2nd option is exacly what I decided to do recently.

      - task: AzureCLI@2
        displayName: "Get Failed ADF Deployment Operations Messages"
        condition: always()
        inputs:
          azureSubscription: "${{ parameters.azure_subscription }}"
          scriptType: "bash"
          scriptLocation: "inlineScript"
          inlineScript: |
              echo 'printing details of failed deployment operations from the ADF ARM template'
              echo 'if array is emtpy it was most likely not an ARM Temaplte deployment issue that caused the ADF to fail.'
              az deployment operation group list --resource-group $(infra.dataFactory.resourceGroup.name) --name $(deployment_name) --query "[?properties.provisioningState=='Failed'].properties.statusMessage.error"
          addSpnToEnvironment: true

If you run this after the deployment has run then you’ll get any errors that your specific deployment generated. This does mean that you’ll need to specify your own deployment_name when running the AzureResourceManagerTemplateDeployment@3 task. And if you’re using the npm package I mentioned right at the top of this post, and are using the prepostdeploymentscript.ps1 file that is part of that package, then you’ll need to either turn off deleting deployments using the switch or edit the file to delete the named deployment. I’ll cover the what/where/how/why of this in another post