If you write code to SQL Server then you might be interested in this: I have written a tSQLt tdd training course which has helped over 500 people learn both tSQLt and how to apply TDD practices to their SQL Server T-SQL development, you can join the course at https://courses.agilesql.club.

Why didnt my Azure ARM deploy work?

I have been using Octopus to deploy ARM templates for a while now and the default task that comes with Octopus to deploy doesn’t have any debugging information enabled and when you run this powershell:

New-AzureRMResourceGroupDeployment

If you don’t have debugging information enabled, the output of a failed deployment is basically “Deployment Failed, suck it up dude” or something along those lines.

If you want to find out why your deployment failed, the best thing to do is grab your template and parameter file and run:

Test-AzureRmResourceGroupDeployment -TemplateFile ./template.json -TemplateParametersFile ./parameters.json -resourceGroup RG-Group -Debug

When you run this, you will be prompted to run the commands - press “a” and then the template, parameters file and deployability are verified and either you are told everything passes, and you can deploy, or you will see the actual error rather than a generic error.

What do you mean the deployability?

Well, it is fairly easy to validate that a template is structurally valid, i.e. is the json well formed but what if you have a concat() on a couple of variables that then point to a non-existant resource? Test-AzureRmResourceGroupDeployment takes care of this, and it will:

  • Parse the JSON structure
  • Parse the template functions
  • Validate references exist or will be created
  • Validates things like VM sizes are available in the specific region chosen
  • Checks the subscription quotas to make sure there is enough to actually deploy

This is useful, and although you don’t know for 100% a deploy will be successful it is normally pretty accurate.

You can also get the debug info by setting your “DebugPreference” to “continue” or using “-Debug” (or DebugPreference) with New-AzureRMResourceGroupDeployment, the test version feels safer though :)

Happy ARMING!

Subscribe

* indicates required

Please select all the ways you would like to hear from Agile Sql Club:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.