在 Azure APIVersion 上使用哪个或两组结果

Which to use or two set of results on Azure APIVersion

场景:列出资源组名称下的 WebApps。

Attempt Approach :

$WebAppApiVersion = "2015-08-01"
$MyResourceGroup = 'gurustorageRG'
Function saymyWebApps($ResourceGroupName)
 {
   Find-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType $myResourceType -ApiVersion $WebAppApiVersion
 }

` saymyWebApps $MyResourceGroup

Output

Find-AzureRmResource : InvalidApiVersionParameter : The api-version '2015-08-01' is invalid. The supported versions are '2017-08-01,2 017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014- 04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'. At line:24 char:5 + Find-AzureRmResource -ResourceGroupName $ResourceGroupName -Resou ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Find-AzureRmResource], ErrorResponseMessageException + FullyQualifiedErrorId : InvalidApiVersionParameter,Microsoft.Azure.Commands.ResourceMan

所以,我从列出的错误输出中为我的 webapiversion 参数选择了 2017-08-01 并重新尝试,奇怪的是它列出了今天创建的 webapps 或者我假设此时可以列出任何应用程序设置 post 仅限 2017-08-01。

Question 1: Does this mean, I would have to pull out available -apiversion and iterate through them to build entire webapp list under a resource group?

Attempted to see -apiversion but the output appears not complete or not matching with error thrown above as in Output block.

用于列出 API 版本的代码段:

Function GetAPIVersions()
 {
 ((Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Web).ResourceTypes | Where-Object ResourceTypeName -eq sites).ApiVersions
}

GetAPIVersions

Output

2016-08-01

2016-03-01

2015-08-01-preview

2015-08-01

2015-07-01

2015-06-01

2015-05-01

2015-04-01

2015-02-01

2014-11-01

2014-06-01

2014-04-01-preview

2014-04-01

以上结果是在成功执行 apiversion 列表片段时得到的。

Question 2: Why is the apiversion listing above not showing the api-versions list as shown in the error output of initial attempt approach?

我们可以使用 fiddler 来捕获 Find-AzureRmResource 的执行,它使用 List Resource API. We could find that the parameter -ApiVersion stands for list resource api 版本与我们要查找的资源类型无关。

Question 2: Why is the apiversion listing above not showing the api-versions list as shown in the error output of initial attempt approach?

您提到 列出 API 版本 for Microsoft.Web ,输出 api 版本可以用来运行WebApp,比如create or update azure webApp

所以-ApiVersionlistAPIversion是不一样的。

总结:

如果我们想使用Find-AzureRmResource命令,我们需要使用错误信息中提到的api版本。

如果我们要查找操作特殊资源类型资源api版本,我们可以使用您提到的列表api方式。