How can I troubleshoot Azure ARM template validation errors? - azure

I have made some small changes to an Azure ARM template file and now when I try to deploy or validate via the xplat cli I get this message.
error: InvalidTemplateDeployment : The template deployment
'fakedDeploymentName' is not valid according to the validation
procedure. The tracking id is '\some kind of GUID here\'.
See inner errors for details. Please see http://aka.ms/arm-deploy for
usage details.
error: PreflightValidationCheckFailed : Preflight
validation failed. Please refer to the details for the specific
errors.
I would love to troubleshoot this problem, but I don't see any "inner errors" on the console. It even gives me a unique GUID each time, implying that I could use this GUID to look up a more informative message. Where can I view a more detailed error? (not looking for help on the real source of the error yet)

Log into the azure portal portal.azure.com.
Open the Activity log
Find the record with Operation Name of Validate in the list of activities. It should have a red exclamation mark because it failed.
Click on it that record. Then click on the JSON tab at the bottom. Get reading and somewhere deep down in returned Json you might find an error in the statusMessage such as "The storage account named helloworld is already taken."

Make sure you're running the latest version of the CLI, we're working on bubbling up the detailed error. If that's still not catching it, let us know https://github.com/Azure/azure-xplat-cli/issues
Then if the log isn't showing you the detail, run the deployment with the -vv switch, the detailed debug output (while verbose) will have all the error messages and you can usually sift through and find the specific failure.
azure group deployment create ... --debug
Powershell:
New-AzResourceGroupDeployment ... -debug

Run the following PowerShell Azure cmdlet with the tracking ID supplied:
Get-AzureRMLog -CorrelationId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -DetailedOutput

Building on nftw's answer...
To make it faster/easier to find the error issue I used grep and less with a variable as follows:
$correlationId ='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' # store your correlation ID here
Get-AzureRmLog -CorrelationId $correlationID -DetailedOutput | grep -C 10 $correlationID | less
In my testing the error was close to the top of the output. You could use less and the forward-slash key / and search "error" to find the error even quicker.

I believe that tracking ID is for technical support for looking at their logs, not for the user.
Regarding your exact question, you need to take a look at logs - reference.
Another good way to validate the template is to use Resource Explorer.

Building on #nftw:
$deploymentGroupName = 'deploymentGroupName'
$correlationId = ((Get-AzureRMLog -ResourceGroup $deploymentGroupName)[0]).CorrelationId
$logentry = (Get-AzureRMLog -CorrelationId $correlationId -DetailedOutput)
#$logentry
$rawStatusMessage = $logentry.Properties
$status = $rawStatusMessage.Content.statusMessage | ConvertFrom-Json
$status.error.details
$status.error.details.details

I was running in the same issue. Basically, I couldn't get any details passed "InvalidTemplateDeployment".
I added my ARM template in a Visual Studio: Azure Resource Group project template and tried to deploy it. I got verbose details in the Output tab. That helped me solve my problem.
In my case it was the name of the cluster, it can only be small letters and numbers.

az vm list [--only-show-errors]
[--resource-group]
[--show-details]
[--subscription]

Related

What does this command do ? "az .\-u"

az .\-u
I accidentally run this command and the cli started some work then I pressed ctrl-c to terminate it but I'm afraid something has been already done. How to check if something changed?
I've checked the cli reference, but couldn't find a similar command.
As there is no such command in Az, even though I entered the same as you, I received an error as shown:
If you want to check your activities for any changes, there are couple of ways:
Check the Log Activity: To check your log activity, use below PowerShell command: (default activity status exists for 90 days)
Get-AzActivityLog -StartTime 2022-11-01T10:30 -EndTime 2022- 11-14T11:30
Note: According to your requirements, you can obtain logs across resource group by applying start time, and end time parameters.
To check for any specific changes held in resources, use below query with "Azcli" command
Search-AzGraph -Query 'resourcechanges | extend changeTime=todatetime(properties.changeAttributes.timestamp) | project changeTime, properties.changeType, properties.targetResourceId, properties.targetResourceType, properties.changes | order by changeTime desc'
Received Output also includes a changetime attribute:
Through Azure portal, Activity logs can also be checked using path: Monitor -> Activity Log
Reference: MSDoc

Azure: what could be the cause of the error "Unable to edit or replace deployment"?

When I recreate my VM I got the following error:
Problem occurred during request to Azure services. Cloud provider details: Unable to edit or replace deployment 'VM-Name': previous deployment from '8/20/2019 6:20:33 AM' is still active (expiration time is '8/27/2019 5:17:41 AM'). Please see https://aka.ms/arm-deploy for usage details.
Help me please to understand.
What could be the cause of the error ?
UPDATED:
This deployment has not been started previously.
Prior to this, errors were received during creation:
Azure is not available now. Please Try again later
There were several such errors one at a time and then I got that error related to:
Unable to edit or replace deployment
My assumptions about this.
Tell me, am I right or not ?
I launched the image, then after some time I recreated it.
Creation began, but at that moment the connection with Azure was lost.
Then, when the connection was restored, we tried to make a deployment that was not removed in the previous attempt (because there was no connection with Azure).
As a result, we got such an error.
Does this theory make sense?
exactly what it says, there is another deployment with the same name going on at this time, either change the name of the deployment you are trying to queue or wait for the other deployment to finish\fail
This can also occur if you use Bicep templates for your ARM deployement and multiple modules or resources in the template have the same name:
module fooModule '../modules/foo.bicep' = {
name: 'foo'
}
module barModule '../modules/bar.bicep' = {
name: 'foo'
}
I got the same error initially pipeline was working but when retriggered pipeline took more time so i canceled the deployment and made a fresh rerun it encounters. i think i need wait until that deployment filed.

Error while creating an Azure Application Insights alert

I'm trying to create a custom log alert with this query:
traces
| where message contains "Setup"
| extend Proposal = tostring(split(split(tostring(message), " ]")[1], ": ")[1])
| summarize AggregatedValue=count() by Time=bin(ago(24h), 1h), Proposal
But I'm getting the error
Search Query should contain 'AggregatedValue' and 'bin(timestamp,
[roundTo])' for Metric alert type
Since I have both requirements of the error, why am I getting it?
Hello and welcome to Stack Overflow!
I tried a similar log query with the same constructs and was able to create a custom log alert successfully. This could be a one-off issue. I'd suggest you to give it another try and see if the error recurs. Else you could also try creating it via other alternate options like ARM templates, Powershell, CLI or REST APIs, as detailed in this doc.

Why is my powershell DSC failing with the message "An item with the same key has already been added"

We have a powershell DSC that is being executed to bring a vmss to a desired state.
It was working until we added some more parameters, and then it broke.
I removed everything except the parameters from the script and it still doesn't work.
The full error is
The DSC Extension received an incorrect input: An error occurred while
executing script or module 'IISInstall.ps1': An item with the same
key has already been added..
Please correct the input and retry executing the extension.
We even added logging in the DSC to try to troubleshoot.
It doesn't even seem to make it into the body of the DSC.
What am I doing wrong?
The parameter was called $instanceName. We wanted to use it to add a custom header to IIS to track which instance a response came from.
Turns out if you use $instanceName that steps on the internals of DSC in some way and it will never deploy correctly!
As soon as you remove $instanceName from the parameter list, it will work.

Error when deploying Azure ML model to modelmanagement

When executing the command below:
az ml model register -m <pkl name>.pkl -n <model name> -d "dummy model" --debug --verbose
I get the error stating that the URL cannot be connected to. The verbose message does not show any error before the one below. I can confirm that the model management account and environments have been set.
I am using the Visual Studio subscription to test out some functionality. Any help is appreciated!
{
"Azure-cli-ml Version": "0.1.0a27.post3",
"Error": "Error connecting to https://australiaeast.modelmanagement.azureml.net/api/subscriptions/ad19a4a2-ed65-4574-aec3-e247c4d96efd/resourceGroups/rcity-rg-bi-001-azureml-3797f/accounts/rcity-bi-mlexpmgmt-002/models."
}
I'm on the Azure Machine Learning team. We'd like to help -- it doesnt look like the command you entered is complete. If you'd like us to help you troubleshoot it, you can email us at amlfb#microsoft.com.
Serina

Resources