Search code examples
azureloggingazure-rm-template

Do ARM templates provide a way to capture the logs during creation of resources


we have ARM template which creates the azure resources. While we run the powershell script which created the resources, we want to log all the info.

we want to know if any logging functionality which azure ARM template provides

the list of resources we are as follows : - storage account - automation account - key-vault - Sql server pool - functionApp etc


Solution

  • Below are some of the general configurations you can use for the New-AzureRmResourceGroupDeployment to get the most amount of logging from the command. You may lookup the equivalent AZ cmdlet, if you need to.

    You can use the -Verbose and -DeploymentDebugLogLevel All parameters to get some more logging info. Note that the Deployment debug parameter will cause a warning to show up in your console output stream.

    You can use the -ErrorVariable ErrorMessages parameter to get the error messages and then use them appropriately in your script.

    Lastly, you can use the JSON output of the cmdlet to get some insights, if any.

    Below is how the cmldet typically looks like for me..

    $jsonOutput = New-AzureRmResourceGroupDeployment -Name  $DeploymentName `
            -ResourceGroupName $ResourceGroupName `
            -TemplateFile $TemplateFileToDeploy `
            -TemplateParameterObject $TemplateParameters `
            -Force -Verbose `
            -ErrorVariable ErrorMessages -DeploymentDebugLogLevel All