ARM模板部署NSG和UDR [英] ARM template deployment NSG and UDR

查看:92
本文介绍了ARM模板部署NSG和UDR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我正忙于创建用于部署不同资源(例如vNet,UDR,NSG等)的ARM模板.为此,我创建了单独的ARM模板,可以将其合并到一个发行版中.

但是有一件事让我烦恼:
当我在Azure DevOps中运行发行版时,它将执行以下步骤:

  1. 创建资源组
  2. 创建vNet并放置资源在步骤1中创建的rg中
  3. 在不同vNet之间创建对等关系
  4. 创建UDR并附加到在步骤2中创建的vNet
  5. 创建NSG 并附加到在第2步中创建的vNet中

但是,在部署步骤5时,它将删除附加的UDR(在步骤4中创建).我认为这是由于以下事实:作为NSG的UDR都在vNet的相同属性部分中附加到vNet.部署第5步后,它将替换 现有配置和第5步的配置(这样,UDR不再连接到vNet).是否交换UDR和NSG步骤的位置并不重要.结果是相同的(或者不使用UDR或不使用NSG,具体取决于 订单).

我正在使用单独的步骤来维护模块化方法.这样,我可以在不同的部署中重用标准的构建基块.我只需要为另一个部署创建另一个参数文件即可.

有人对此问题有解决方案吗?还是设计使然?

解决方案

是的.我认为原样直接使用完整的ARM模板,您将无法 add 属性,并最终替换.

此处是一个与NSG相似但功能相似的示例.您也应该能够对UDR遵循相同的条件.

想法是使用增量部署模式,而不是默认模式 完成模式.完全模式基本上会覆盖/删除,使您的资源进入ARM模板中定义的状态,而增量模式将追加.

确实讨论了更多有关部署模式和 这里是示例中使用的Microsoft.Resources/deployments类型的参考.


Hi there!

I'm busy creating ARM templates for the deployment of different resources, such as vNet, UDR, NSG, etc... For this I create separate ARM templates, which I can combine in a single release. 

But one thing annoyed me:
When I run my release within Azure DevOps it performs the following steps:

  1. create resource group 
  2. create vNet and place resource in rg created in step 1
  3. create peering between different vNets 
  4. Create UDR and attach to vNet created in step 2
  5. Create NSG and attach to vNet created in step 2

But when step 5 is being deployed, it removes the attached UDR (Created in step 4). I think this is due to the fact both the UDR as the NSG is attached to the vNet in the same properties section of the vNet. When step 5 is being deployed, it replaces the existing configuration with the configuration of step 5 (And this way the UDR is no longer attached to the vNet). It does not matter if I swap the location of the UDR and NSG steps. The result is the same (Or UDR is not used, or NSG is not used depending on the order).

I'm using separate steps to maintain a modular approach. This way I can reuse standard building blocks in different deployments. I only have to create another parameter file for another deployment. 

Does anyone have a solution for this problem? Or is this by design?

解决方案

Yes. I think it were to directly use the complete ARM template as-is, you won't be able to add properties and end up replacing them.

Here is a sample which does something similar but just with an NSG. You should able to follow the same for UDR as well.

The idea is to use the Incremental Deployment Mode instead of the default Complete mode. Complete mode basically overrides / deletes bringing your resources to the state defined in your ARM Template while Incremental mode appends instead.

This does talks more about the deployment modes and here is the reference for the Microsoft.Resources/deployments type used in the sample.


这篇关于ARM模板部署NSG和UDR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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