如何知道 IaC Azure 资源是否需要特定名称而不运行部署并且部署失败?

问题描述 投票:0回答:1

有时我会向我的二头肌添加资源,但会失败,因为名称不正确。

例如,虚拟机关闭计划:

resource vmAutoShutdown 'Microsoft.DevTestLab/schedules@2018-09-15' = {
  name: '${vm.name}-autoshutdown'
  location: location
  //<snip>
}

不允许使用该名称 - 必须是

'shutdown-computevm-${vm.name}'

或对 Azure Blob 存储容器进行病毒扫描:

resource defenderForStorageSettings 'Microsoft.Security/DefenderForStorageSettings@2022-12-01-preview' = if (enableVirusScanning)  {
  name: '${storage.name}-antivirus'
  scope: storage
  //<snip>
}

不,一定是

name: 'current'

有没有办法找到这个问题或验证不需要运行实际部署的名称?

azure azure-resource-manager azure-rm-template azure-bicep
1个回答
0
投票

根据我的经验,没有简单的方法可以知道这一点。我通常做的是检查 Azure 模板参考以获取我想要部署的特定 Azure 资源,您可以从此文档中轻松找到 Bicep、ARM 和 Terraform 中 Azure 资源的所有可用选项。

https://learn.microsoft.com/en-us/azure/templates/

然后我还参考了 Azure 资源名称规则文档来了解我使用的每个服务的不同命名要求。根据您使用的服务,存在各种限制。您可以在本文档中找到 Azure 资源命名规则和限制。

https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules

© www.soinside.com 2019 - 2024. All rights reserved.