Azure Bicep\ARM - 获取资源命名的缩短区域名称

标签 azure azure-resource-manager azure-bicep

我正在尝试编写一个通用的 Bicep 文件来创建存储帐户。我在创建资源时尝试遵循标准命名约定,例如:它将类似于 st<storage name><location-code><###> 。 我想做的是参数化“位置”值。如果我这样做,我怎样才能将缩写的“区域代码”放入名称中。例如:如果我通过美国中部作为区域,则名称将为 sttestcus001。如果我输入 East US,名称将为 sttesteus001。

谢谢

最佳答案

您始终可以维护一个为您进行映射的对象:

param location string = 'Central US'

// Object containing a mapping for location / region code
var regionCodes = {
  centralus: 'cus'
  eastus: 'eus'
}

// remove space and make sure all lower case
var satinatizedLocation = toLower(replace(location, ' ', ''))

// get the region code
var regionCode = regionCodes[satinatizedLocation]

关于Azure Bicep\ARM - 获取资源命名的缩短区域名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73862508/

相关文章:

azure - 系统为 Azure 逻辑应用生成的电子邮件

Azure 二头肌模块 : Can modules be referenced from a separate repo?

azure - 无法将网站部署到 Azure "String larger than expected"

azure - 如何将现有路由表添加到子网

Azure 资源管理器模板 HostingEnvironment

azure - 如何将自定义模块添加到 ARM 模板

azure - 使用 bicep 部署逻辑应用 - 将 JSON 转换为有效的 Bicep

azure - 无法使用 Azure Bicep 创建资源组

c# - Azure Functions 的 Node.js 与 C# : How to choose regarding performance and integration

azure - 在哪里可以获取 LUIS 订阅 key ?