gpt4 book ai didi

azure - 为什么二头肌中不推荐使用 'dependsOn'?

转载 作者:行者123 更新时间:2023-12-02 05:55:40 26 4
gpt4 key购买 nike

微软 documents隐式和显式依赖的目的。其中显式依赖项使用“dependsOn”。但有人提到这种方法的用例很少。

可以对以下内容进行一些澄清:

来自 MS 的示例

resource dnsZone 'Microsoft.Network/dnszones@2018-05-01' = {
name: 'demoeZone1'
location: 'global'
}

resource otherZone 'Microsoft.Network/dnszones@2018-05-01' = {
name: 'demoZone2'
location: 'global'
dependsOn: [
dnsZone
]
}

报价

You can't query which resources were defined in the dependsOn element after deployment.

假设“otherZone”是一个dependsOn元素,仍然可以使用符号名称来查询它。

我错了吗?如果是的话,dependsOn 元素是什么意思?

最佳答案

正如您链接到的文章中所述:

The following example shows a DNS zone named otherZone that depends on a DNS zone named dnsZone

这意味着 otherZone 不是 dependentOn 元素,它依赖于 dnsZone

While you may be inclined to use dependsOn to map relationships between your resources, it's important to understand why you're doing it. For example, to document how resources are interconnected, dependsOn isn't the right approach. You can't query which resources were defined in the dependsOn element after deployment. Setting unnecessary dependencies slows deployment time because Resource Manager can't deploy those resources in parallel.

Bicep 自动(隐式)创建依赖项

Azure Resource Manager evaluates the dependencies between resources, and deploys them in their dependent order. When resources aren't dependent on each other, Resource Manager deploys them in parallel.

因此在大多数情况下不需要显式设置它们。

关于azure - 为什么二头肌中不推荐使用 'dependsOn'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71320257/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com