Создайте учетную запись StorageV2 Storage в шаблоне управления ресурсами Azure. - PullRequest
0 голосов
/ 13 июня 2018

Я пытаюсь создать шаблон ARM, который включает в себя создание учетной записи хранения.

Я хочу создать учетную запись StorageV2 (general purpose v2), но, похоже, это не удалось, поскольку 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."
}

Можно ли создать учетную запись хранения V2 с использованием шаблонов ARM?

1 Ответ

0 голосов
/ 13 июня 2018

Вам необходимо обновить 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

И написал статью об этом в блоге: Определите последнюю версию API для поставщика ресурсов

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...