0

Trying to create a storage account and I run into problems that StorageAccountAlredyTaken.

What is best practice of doing this?

// getting paramerts from json file
param storageName string

//pseudo code
1. get length of storageName
2. add random string behind "storageName" and add a random length of x-characters so that the storage name get 24 characters

ex storageName = rg-supercode-dev-westeurope-(storageName has the total of 24 characters length)

4

1 回答 1

0

谢谢Daniel MannTrevorBrooks。发布您的建议作为帮助其他社区成员的答案。

您可以使用uniqueString包含唯一存储帐户名称的名称。

以下示例显示如何根据您的资源组为存储帐户创建唯一名称。在资源组内,如果以相同方式构造,则名称不是唯一的。

JSON

"resources": [{
  "name": "[concat('storage', uniqueString(resourceGroup().id))]",
  "type": "Microsoft.Storage/storageAccounts",
  ...

ARM模板可以参考uniqueString

于 2021-10-05T10:32:52.143 回答