Azure ARM模板嵌套模板部署不会更新资源\无法启动 [英] Azure ARM template nested template deployment won't update resources\fails to start

查看:112
本文介绍了Azure ARM模板嵌套模板部署不会更新资源\无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下ARM模板结构:

I have the following ARM Template structure:

Parent Template
  |--Nested Template 1 
  |--...
  |--Nested Template 6

所以我只有2个级别的模板:父"模板和嵌套"模板.

So I only have 2 levels of templates, Parent and nested.

可以说我将父级部署到一个空的资源组中,并且一切正常.之后,我删除其中一个资源,并希望使用相同的参数来部署相同的父模板,以将已删除的资源带回.但是部署将无法说资源已经存在(另一个,不是我尝试重新创建的资源).我尝试了增量模式和完全模式进行部署. 如果我直接使用缺少的资源调用嵌套模板,则它可以按预期工作(因此,仅使用嵌套模板创建部署,而不是使用调用嵌套模板的父级创建部署).

Lets say I deploy parent to an empty resource group and everything works well. After that I delete one of the resources and want to deploy the same Parent Template with the same parameters to bring deleted resources back. But the deployment would fail saying that the resource already exists (the other, not the one i'm tried to recreate). I tried both incremental mode and full mode for deployments. If i directly invoke nested template with the missing resources it works as expected (so specifically creating a deployment with nested template only, not with parent that invokes nested template).

UPD: 经过一些额外的测试,我可以得出结论,那就是之前的怪异.因此,我将使用powershell开始此部署:

UPD: After some additional testing I can conclude thats even weirder then before. So I'm starting this deployment with powershell:

New-AzureRmResourceGroupDeployment @parameters

New-AzureRmResourceGroupDeployment @parameters

它可以很好地部署,但是如果我在第一次部署完成后调用相同的命令,则会收到错误消息:

And it deploys just fine, however if I invoke the same command after the first deployment completed I would get an error:

资源"gggg-1s-the-wordd"已存在于位置 资源组"gggg"中的"westeurope".具有相同名称的资源 不能在北theurope"位置创建.请选择一个新的 资源名称.

The resource 'gggg-1s-the-wordd' already exists in location 'westeurope' in resource group 'gggg'. A resource with the same name cannot be created in location 'northeurope'. Please select a new resource name.

此行为是否例外?我似乎找不到任何相关内容,谢谢!

Is this behavior excepted? I can't seem to find anything relevant, thanks!

UPD2:使用门户网站或Powershell并不重要,我会遇到相同的错误.

UPD2: It doesn't really matter if I use portal or powershell, I get the same error.

推荐答案

因此,在Brian的帮助下,我们得以找出了罪魁祸首.问题在于,Web应用程序的位置设置为resourcegroup().location,而App Service Plan正确地从参数获取了位置.这就导致了一个问题,即在部署时WebApp会部署到其App Service Plan所在的区域,而在评估时它将认为该WebApp属于资源组所在的区域. TLDR-复制粘贴错误,再加上ARM中位置评估的错误,导致行为异常.

So with the help from Brian we were able to identify the culprit. The issue was that the WebApp had its location set to resourcegroup().location while the App Service Plan was correctly getting location from parameters. So that lead to a problem where at deployment time WebApp would deploy to the region where its App Service Plan was, but at evaluation time it would consider that this WebApp belongs to the region where the resource group was. TLDR - copy paste error, which coupled with a bug in evaluation of location in ARM lead to a quite weird behavior.

这篇关于Azure ARM模板嵌套模板部署不会更新资源\无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆