简体   繁体   English

移动Azure资源并使用ARM模板更新它们

[英]Moving Azure resources and update them with an ARM template

移动资源很容易,但是使用'uniqueString(resourceGroup()。id)'的ARM模板是否仍会更新移动的资源或创建新的资源?

It will create new resources. 它将创造新的资源。 From the documentation on uniquestring it creates a deterministic unique hash from the parameters. uniquestring文档中,它根据参数创建确定性唯一哈希。 You're feeding the resourceGroup id to create the hash. 您正在输入resourceGroup id以创建哈希。 If that resource group id changes, so will the hash. 如果该资源组ID更改,则哈希也将更改。

If you're appending a value to create uniqueness - a simple way is to change the template to refer to a variable called suffix, and directly assign the previously created unique id to the suffic variable. 如果要附加值以创建唯一性-一种简单的方法是更改​​模板以引用名为后缀的变量,然后将先前创建的唯一ID直接分配给后缀变量。

If you wanted to create a portable, reusable template that would allow you to move resources between groups, then you'll need a different value to seed your deterministic hash, and not something that's likely to change. 如果您想创建一个可移植,可重用的模板,允许您在组之间移动资源,那么您将需要一个不同的值来播种确定性哈希,而不是可能会改变的值。 I use subscription().id frequently. 我经常使用subscription()。id。

Another thing to look at is the template function documentation which allows you to define your own functions. 要看的另一件事是模板功能文档 ,它允许您定义自己的功能。 You can encapsulate the unique naming logic in there also. 您也可以在其中封装唯一的命名逻辑。

Probably not the answer you wanted to here though. 虽然可能不是您想要的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM