简体   繁体   English

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

[英]Azure Bicep\ARM - Get shortened region name for resource naming

I am trying to write a generic Bicep file that creates a storage account.我正在尝试编写一个创建存储帐户的通用二头肌文件。 I am trying to following the standard naming convention when creating the resource, eg: it would be something like st<storage name><location-code><###> .我在创建资源时尝试遵循标准命名约定,例如:它类似于st<storage name><location-code><###> What I want to do is parameterize the 'location' value.我想要做的是参数化“位置”值。 If I do this though, how can I get the abbreviated 'region code' to put in the name.如果我这样做,我怎样才能得到缩写的“区域代码”来输入名称。 Eg: If I pass in Central US as the region, the name would be sttestcus001.例如:如果我通过美国中部作为区域,名称将是 sttestcus001。 If I put in East US, the name would be sttesteus001.如果我输入美国东部,名称将是 sttesteus001。

Thanks,谢谢,

You could always maintain an object that will do the mapping for you:您始终可以维护一个 object 来为您进行映射:

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]

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

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