我试图创建一个包含创建存储帐户的ARM模板。
我想创建一个StorageV2 (general purpose v2)
帐户,但这似乎失败了,因为schema中不存在StorageV2
。
{
"name": "[variables('xblobstorageName')]",
"type": "Microsoft.Storage/storageAccounts",
"location": "[resourceGroup().location]",
"apiVersion": "2016-01-01",
"sku": {
"name": "[parameters('xblobstorageType')]"
},
"dependsOn": [],
"tags": {
"displayName": "xblobstorage"
},
"kind": "StorageV2"
}
kind
唯一允许的值为Storage
和BlobStorage
,因此在尝试部署上述模板时会收到以下错误:
"error": {
"code": "AccountPropertyIsInvalid",
"message": "Account property kind is invalid for the request."
}
是否可以使用ARM模板创建V2存储帐户?
答案 0 :(得分:3)
您必须更新 apiVersion 到2018-02-01
。
我编写了一个PowerShell脚本来确定资源提供者的最新API版本:
<#
.Synopsis
Gets the latest API version of a resource provider
.DESCRIPTION
The following cmdlet returns the latest API version for the specified resource provider.
You can also include pre-release (preview) versions using the -IncludePreview switch
.EXAMPLE
Using the Full Parameter Set:
Get-AzureRmResourceProviderLatestApiVersion -Type Microsoft.Storage/storageAccounts
.EXAMPLE
Using the Full Parameter Set with the -IncludePreview switch:
Get-AzureRmResourceProviderLatestApiVersion -Type Microsoft.Storage/storageAccounts -IncludePreview
.EXAMPLE
Using the ProviderAndType Parameter Set:
Get-AzureRmResourceProviderLatestApiVersion -ResourceProvider Microsoft.Storage -ResourceType storageAccounts
#>
function Get-AzureRmResourceProviderLatestApiVersion
{
[CmdletBinding()]
[Alias()]
[OutputType([string])]
Param
(
[Parameter(ParameterSetName = 'Full', Mandatory = $true, Position = 0)]
[string]$Type,
[Parameter(ParameterSetName = 'ProviderAndType', Mandatory = $true, Position = 0)]
[string]$ResourceProvider,
[Parameter(ParameterSetName = 'ProviderAndType', Mandatory = $true, Position = 1)]
[string]$ResourceType,
[switch]$IncludePreview
)
# retrieving the resource providers is time consuming therefore we store
# them in a script variable to accelerate subsequent requests.
if (-not $script:resourceProvider)
{
$script:resourceProvider = Get-AzureRmResourceProvider
}
if ($PSCmdlet.ParameterSetName -eq 'Full')
{
$ResourceProvider = ($Type -replace "\/.*")
$ResourceType = ($Type -replace ".*?\/(.+)", '$1')
}
$provider = $script:resourceProvider |
Where-Object {
$_.ProviderNamespace -eq $ResourceProvider -and
$_.ResourceTypes.ResourceTypeName -eq $ResourceType
}
if ($IncludePreview)
{
$provider.ResourceTypes.ApiVersions[0]
}
else
{
$provider.ResourceTypes.ApiVersions | Where-Object {
$_ -notmatch '-preview'
} | Select-Object -First 1
}
}
用法:
Get-AzureRmResourceProviderLatestApiVersion -Type Microsoft.Storage/storageAccounts
写了一篇关于它的博客文章: Determine latest API version for a resource provider