ARM Template error code invalidTemplate "Circular Dependancy Detected - arm-template

I am new to deploying ARM templates. Before I created the ARM template I created a simple infrastructure consisting of 1 VM, 1 VNet, and 1 storage account. Once I finished provisioning the infrastructure, I decided to make a template for future use. I went under automation scripts, and I saved it to the library and I saved the changes and then I decided to test it out by deploying the template. After this, I got an error code that says the following:
Deployment template validation failed: 'Circular dependency detected on resource: '/subscriptions/7b790d29-944d-4f0f-861b-928e4774cde9/resourceGroups/SimpleRev2/providers/Microsoft.Network/networkInterfaces/simplevm18'. Please see https://aka.ms/arm-template/#resources for usage details.'. (Code: InvalidTemplate)
So what should i do please guide?

Related

Azure pipeline Release pipeline: ARM Template deployment: Resource Group scope fails with ,,Error code: DeploymentFailed"

The ARM template seems fine, no validation errors occur, and variables seem to be defined, not sure how should I debug this weird error message.
2023-01-25T16:46:49.4710207Z ==============================================================================
2023-01-25T16:46:49.4710434Z Task : ARM template deployment
2023-01-25T16:46:49.4710576Z Description : Deploy an Azure Resource Manager (ARM) template to all the deployment scopes
2023-01-25T16:46:49.4710814Z Version : 3.210.1
2023-01-25T16:46:49.4710932Z Author : Microsoft Corporation
2023-01-25T16:46:49.4711075Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment
2023-01-25T16:46:49.4711307Z ==============================================================================
2023-01-25T16:46:49.6711981Z ARM Service Connection deployment scope - Subscription
2023-01-25T16:46:49.6897349Z Checking if the following resource group exists: APP-RG-DEV-NE.
2023-01-25T16:46:49.9703739Z Resource group exists: true.
2023-01-25T16:46:49.9707493Z Creating deployment parameters.
2023-01-25T16:46:50.7941256Z Starting template validation.
2023-01-25T16:46:50.8120966Z Deployment name is azuredeploy-20230125-164650-9976
2023-01-25T16:46:55.8082119Z Template deployment validation was completed successfully.
2023-01-25T16:46:55.8082485Z Starting Deployment.
2023-01-25T16:46:55.8083063Z Deployment name is azuredeploy-20230125-164650-9976
2023-01-25T16:48:05.5609488Z There were errors in your deployment. Error code: DeploymentFailed.
2023-01-25T16:48:05.5641699Z ##[error]At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.
2023-01-25T16:48:05.5651004Z ##[error]Details:
2023-01-25T16:48:05.5651895Z ##[error]BadRequest:
2023-01-25T16:48:05.5652688Z ##[error]BadRequest:
2023-01-25T16:48:05.5653453Z ##[error]BadRequest:
2023-01-25T16:48:05.5654221Z ##[error]BadRequest:
2023-01-25T16:48:05.5654988Z ##[error]BadRequest:
2023-01-25T16:48:05.5656695Z ##[error]Check out the troubleshooting guide to see if your issue is addressed: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment?view=azure-devops#troubleshooting
2023-01-25T16:48:05.5658246Z ##[error]Task failed while creating or updating the template deployment.
2023-01-25T16:48:05.5682468Z ##[section]Finishing: ARM Template deployment: Resource Group scope
```
Ok found the issue, which was pretty stupid not sure why the error message was not clearer about name violations.
The secret name for the key vault contained a dot (.) in it and was failing because of it.

Deploy an ARM template on DevTestLab failure - missing snapshot error

Prerequisites:
DevTest Lab with Azure Repos connected (as a source for ARM Templates)
working ARM template
Custom images in that DTLab
You try to deploy an ARM template and all deployments fail with error:
Please note, that the mentioned in error message snapshot ("mshasstupiderrors") is not mentioned in ARM template (in my case, I've used only standard Windows Server 2019).
The fix is to check if there is a custom image in that DTLab with the name "mshasstupiderrors" which is missing a connected snapshot.
This post is triggered by 7 months of support case battle with MS - they agreed that this an issue (ARM template deployment validation?), but were not able to find a reason asked to close the ticket...

Debug ARM template

I'm working on an ARM template containing APIs of an API Management resource, that have been generated by Azure API Management DevOps Resource Kit.
The ARM template is more than 50,000 lines and when I try to deploy it, I get this error:
InvalidTemplate - Deployment template language expression evaluation failed: 'Unable to parse language expression ' ': expected token 'Identifier' and actual 'EndOfData'.'. Please see https://aka.ms/arm-template-expressions for usage details.
This error doesn't contains any information on the location of the error in my template and the file is too large to be debugged manually.
Is there a tool that could allow to debug an ARM Template with more precise information? (Especially that could gives the line on which the error occurs).
You can use the azure client to syntactically validate the template:
az group deployment validate
--resource-group <rg-name>
--template-file <arm-name>
or if you prefer PowerShell:
Test-AzureRmResourceGroupDeployment
-ResourceGroupName <rg-name>
-TemplateFile <arm-name>
Also, in VSCode (or other IDEs like Rider) you can download the ARM plugin to easily spot errors like these.
Try the extension for visual studio code: https://marketplace.visualstudio.com/items?itemName=msazurermtools.azurerm-vscode-tools
It will give you Intellisense for the ARM template and maybe then you will find the error.
I found the tool provided by Microsoft itself very useful.
arm-ttk is a powershell script that checks your createUIDefinition.json and your mainTemplate.json.
The only downside is that it is bases on powershell and if you are on linux you first have to install pwsh.
Alternatively you can use a docker container.

Validation error deploying Azure Functions using Azure DevOps

I am facing validation error while deploying Azure Functions using Azure DevOps. Please find the below error.
I am using ARM template and parameterized. If i provide a new storage account name am able to deploy from DevOps, if i use an existing storage account name, getting below error. Any suggestions?
The template deployment 'azuredeploy-20200714-XXXXXX-gjhj' is not
valid according to the validation procedure. The tracking id is
'XXXXXXXX'. See inner errors for details. Details:
PreflightValidationCheckFailed: Preflight validation failed. Please
refer to the details for the specific errors.
[{"code":"InvalidValuesForRequestParameters","target":"","message":"Values
for request parameters are invalid: kind."}] At least one resource
deployment operation failed. Please list deployment operations for
details. Please see https://aka.ms/DeployOperations for usage details.
Details: InvalidValuesForRequestParameters: Values for request
parameters are invalid: kind. Check out the troubleshooting guide to
see if your issue is addressed:
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment?view=azure-devops#troubleshooting
Task failed while creating or updating the template deployment.

Arm template validation fails through Azure Devops release, works from powershell and test-AzResourceGroupDeployment

I have a release setup that I'm trying get out through Azure Devops release pipelines. This is based on another release that I've cloned and works fine.
The issue is that the template is failing a validation check and not going any further. Strange thing is i'm able to check the syntax successfully with new-AzResourceGroupDeployment and test-AzResourceGroupDeployment. It reports no errors and has been deploying fine.
Using Azure Devops release the error coming back is:
2020-02-26T12:26:16.2632844Z ==============================================================================
2020-02-26T12:26:16.2633634Z Task : ARM template deployment
2020-02-26T12:26:16.2634204Z Description : Deploy an Azure Resource Manager (ARM) template to all the deployment scopes
2020-02-26T12:26:16.2634534Z Version : 3.1.19
2020-02-26T12:26:16.2634945Z Author : Microsoft Corporation
2020-02-26T12:26:16.2635504Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment
2020-02-26T12:26:16.2635948Z ==============================================================================
2020-02-26T12:26:16.8677026Z ARM Service Conection deployment scope - Subscription
2020-02-26T12:26:16.8760315Z Checking if the following resource group exists: myResourceGroup.
2020-02-26T12:26:17.2234188Z Resource group exists: true.
2020-02-26T12:26:17.2259290Z Creating deployment parameters.
2020-02-26T12:26:17.2558066Z The detected encoding for file 'd:\a\r1\a\_Azure-Infrastructure\myResourceGroup\deployment\azuredeploy.json' is 'utf-8'
2020-02-26T12:26:17.2561303Z The detected encoding for file 'd:\a\r1\a\_Azure-Infrastructure\myResourceGroup\deployment\param.dev.json' is 'utf-8'
2020-02-26T12:26:17.5304032Z Starting template validation.
2020-02-26T12:26:17.5304834Z Deployment name is Release-vstfs:///ReleaseManagement/Release/95
2020-02-26T12:26:17.5877973Z ##[warning]Validation errors were found in the Azure Resource Manager template. This can potentially cause template deployment to fail. Template validation failed. Error: {"message":"No HTTP resource was found that matches the request URI 'https://management.azure.com/subscriptions/mySubscription/resourcegroups/myResourceGroup/providers/Microsoft.Resources/deployments/Release-vstfs:/ReleaseManagement/Release/95/validate?api-version=2017-05-10'."}.. Please follow https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-syntax
2020-02-26T12:26:17.5890527Z Starting Deployment.
2020-02-26T12:26:17.5891348Z Deployment name is Release-vstfs:///ReleaseManagement/Release/95
2020-02-26T12:26:17.6289831Z There were errors in your deployment. Error code: undefined.
2020-02-26T12:26:17.6291819Z ##[error][object Object]
2020-02-26T12:26:17.6295387Z ##[error]Task failed while creating or updating the template deployment.
2020-02-26T12:26:17.6399260Z ##[section]Finishing: ARM Template deployment: Resource Group scope
​Looking the log above, I'm not sure if it's failing on the validation errors or on the error near the end with a undefined error code.
The task is from another subscription and it's listed in the Azure Resource Manager connection on the task and also lists the subscription and the resource groups in the subscription.
Anyone any ideas on how I can get this working or where to start troubleshooting?
your deployment name is:
Release-vstfs:/ReleaseManagement/Release/95
fairly certain that's not allowed (/). so you need to set your deployment name to something reasonable.
ps. : might not be allowed as well
Did you look at the Activity Log in Azure portal?
All deployment attempts are logged here. Look in particular at the JSON pane, often the real issue is only displayed here.
Otherwise, if it doesn't reach Azure, can you double check the service connection in Azure DevOps? (in particular the related user permission in Azure)

Resources