Azure 資源提供者和類型Azure resource providers and types

部署資源時,您經常需要擷取有關資源提供者和類型的資訊。When deploying resources, you frequently need to retrieve information about the resource providers and types. 例如,如果想要儲存金鑰和密碼,您會使用 Microsoft.KeyVault 資源提供者。For example, if you want to store keys and secrets, you work with the Microsoft.KeyVault resource provider. 此資源提供者會提供稱為保存庫的資源類型來建立金鑰保存庫。This resource provider offers a resource type called vaults for creating the key vault.

資源類型名稱的格式:{resource-provider}/{resource-type}The name of a resource type is in the format: {resource-provider}/{resource-type}. 金鑰保存庫的資源類型是 Microsoft.KeyVault/vaultsThe resource type for a key vault is Microsoft.KeyVault/vaults.

在本文中,您將學會如何:In this article, you learn how to:

  • 在 Azure 中檢視所有資源提供者View all resource providers in Azure
  • 檢查資源提供者的註冊狀態Check registration status of a resource provider
  • 註冊資源提供者Register a resource provider
  • 檢視資源提供者的資源類型View resource types for a resource provider
  • 檢視資源類型的有效位置View valid locations for a resource type
  • 檢視資源類型的有效 API 版本View valid API versions for a resource type

您可以透過 Azure 入口網站、Azure PowerShell 或 Azure CLI 來執行這些步驟。You can do these steps through the Azure portal, Azure PowerShell, or Azure CLI.

如需將資源提供者對應至 Azure 服務的清單,請參閱 Azure 服務的資源提供者For a list that maps resource providers to Azure services, see Resource providers for Azure services.

註冊資源提供者Register resource provider

使用資源提供者之前,您必須為您的 Azure 訂用帳戶註冊資源提供者。Before using a resource provider, you must register the resource provider for your Azure subscription. 此步驟會將您的訂用帳戶設定為使用資源提供者。This step configures your subscription to work with the resource provider. 註冊範圍一律是訂用帳戶。The scope for registration is always the subscription. 許多資源提供者都會預設為自動註冊。By default, many resource providers are automatically registered. 不過,您可能需要手動註冊某些資源提供者。However, you may need to manually register some resource providers.

本文說明如何檢查資源提供者的註冊狀態,並視需要進行註冊。This article shows you how to check the registration status of a resource provider, and register it as needed. 您必須擁有對資源提供者進行作業的許可權 /register/actionYou must have permission to do the /register/action operation for the resource provider. 許可權包含在「參與者」和「擁有者」角色中。The permission is included in the Contributor and Owner roles.

您的應用程式程式碼不應針對處於 註冊 狀態的資源提供者封鎖資源的建立。Your application code shouldn't block the creation of resources for a resource provider that is in the registering state. 當您註冊資源提供者時,會針對每個支援的區域個別執行此作業。When you register the resource provider, the operation is done individually for each supported region. 若要在區域中建立資源,註冊只需要在該區域中完成。To create resources in a region, the registration only needs to be completed in that region. 藉由不封鎖註冊狀態的資源提供者,您的應用程式可以比等候所有區域完成更快。By not blocking resource provider in the registering state, your application can continue much sooner than waiting for all regions to complete.

當您的訂用帳戶中仍有來自該資源提供者的資源類型時,您無法取消註冊資源提供者。You can't unregister a resource provider when you still have resource types from that resource provider in your subscription.

Azure 入口網站Azure portal

若要查看所有資源提供者,以及您訂用帳戶的登錄狀態:To see all resource providers, and the registration status for your subscription:

  1. 登入 Azure 入口網站Sign in to the Azure portal.

  2. 在 Azure 入口網站功能表上,選取 [所有服務]。On the Azure portal menu, select All services.

    選取 [訂用帳戶]

  3. 在 [所有服務]**** 方塊中,輸入 [訂用帳戶]****,然後選取 [訂用帳戶]****。In the All services box, enter subscription, and then select Subscriptions.

  4. 從訂用帳戶清單中選取要檢視的訂用帳戶。Select the subscription from the subscription list to view.

  5. 選取資源提供者並檢視可用資源提供者的清單。Select Resource providers and view the list of available resource providers.

    顯示資源提供者

  6. 若要註冊資源提供者,請選取 [註冊]****。To register a resource provider, select Register. 在前一個螢幕擷取畫面中,已針對 Microsoft.Blueprint 醒目提示 [註冊]**** 連結。In the previous screenshot, the Register link is highlighted for Microsoft.Blueprint.

若要查看特定資源提供者的資訊:To see information for a particular resource provider:

  1. 登入 Azure 入口網站Sign in to the Azure portal.

  2. 在 Azure 入口網站功能表上,選取 [所有服務]。On the Azure portal menu, select All services.

  3. 在 [所有服務]**** 方塊中,輸入 [資源總管]****,然後選取 [資源總管]****。In the All services box, enter resource explorer, and then select Resource Explorer.

    選取所有服務

  4. 選取向右箭號可展開 [提供者]****。Expand Providers by selecting the right arrow.

    選取 [提供者]

  5. 展開資源提供者和您想要檢視的資源類型。Expand a resource provider and resource type that you want to view.

    選取 [資源類型]

  6. 所有區域都支援資源管理員,但您部署的資源可能無法在所有區域中受到支援。Resource Manager is supported in all regions, but the resources you deploy might not be supported in all regions. 此外,您的訂用帳戶可能會有限制,以防止您使用某些支援該資源的區域。Also, there may be limitations on your subscription that prevent you from using some regions that support the resource. 資源總管會顯示資源類型的有效位置。The resource explorer displays valid locations for the resource type.

    顯示位置

  7. API 版本會對應至資源提供者所發行的 REST API 作業版本。The API version corresponds to a version of REST API operations that are released by the resource provider. 當資源提供者啟用新功能時,它會發行新版本的 REST API。As a resource provider enables new features, it releases a new version of the REST API. 資源總管會顯示資源類型的有效 API 版本。The resource explorer displays valid API versions for the resource type.

    顯示 API 版本

Azure PowerShellAzure PowerShell

注意

本文已更新為使用新的 Azure PowerShell Az 模組。This article has been updated to use the new Azure PowerShell Az module. AzureRM 模組在至少 2020 年 12 月之前都還會持續收到錯誤 (Bug) 修正,因此您仍然可以持續使用。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要深入了解新的 Az 模組和 AzureRM 的相容性,請參閱新的 Azure PowerShell Az 模組簡介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 如需 Az 模組安裝指示,請參閱安裝 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

若要查看 Azure 中的所有資源提供者,以及您訂用帳戶的登錄狀態,請使用:To see all resource providers in Azure, and the registration status for your subscription, use:

Get-AzResourceProvider -ListAvailable | Select-Object ProviderNamespace, RegistrationState

傳回的結果類似於:Which returns results similar to:

ProviderNamespace                RegistrationState
-------------------------------- ------------------
Microsoft.ClassicCompute         Registered
Microsoft.ClassicNetwork         Registered
Microsoft.ClassicStorage         Registered
Microsoft.CognitiveServices      Registered
...

若要註冊資源提供者,請使用:To register a resource provider, use:

Register-AzResourceProvider -ProviderNamespace Microsoft.Batch

傳回的結果類似於:Which returns results similar to:

ProviderNamespace : Microsoft.Batch
RegistrationState : Registering
ResourceTypes     : {batchAccounts, operations, locations, locations/quotas}
Locations         : {West Europe, East US, East US 2, West US...}

若要查看特定資源提供者的資訊,請使用:To see information for a particular resource provider, use:

Get-AzResourceProvider -ProviderNamespace Microsoft.Batch

傳回的結果類似於:Which returns results similar to:

{ProviderNamespace : Microsoft.Batch
RegistrationState : Registered
ResourceTypes     : {batchAccounts}
Locations         : {West Europe, East US, East US 2, West US...}

...

若要查看資源提供者的資源類型,請使用:To see the resource types for a resource provider, use:

(Get-AzResourceProvider -ProviderNamespace Microsoft.Batch).ResourceTypes.ResourceTypeName

它會傳回:Which returns:

batchAccounts
operations
locations
locations/quotas

API 版本會對應至資源提供者所發行的 REST API 作業版本。The API version corresponds to a version of REST API operations that are released by the resource provider. 當資源提供者啟用新功能時,它會發行新版本的 REST API。As a resource provider enables new features, it releases a new version of the REST API.

若要取得資源類型的可用 API 版本,請使用:To get the available API versions for a resource type, use:

((Get-AzResourceProvider -ProviderNamespace Microsoft.Batch).ResourceTypes | Where-Object ResourceTypeName -eq batchAccounts).ApiVersions

它會傳回:Which returns:

2017-05-01
2017-01-01
2015-12-01
2015-09-01
2015-07-01

所有區域都支援資源管理員,但您部署的資源可能無法在所有區域中受到支援。Resource Manager is supported in all regions, but the resources you deploy might not be supported in all regions. 此外,您的訂用帳戶可能會有限制,以防止您使用某些支援該資源的區域。Also, there may be limitations on your subscription that prevent you from using some regions that support the resource.

若要取得資源類型支援的位置,請使用:To get the supported locations for a resource type, use.

((Get-AzResourceProvider -ProviderNamespace Microsoft.Batch).ResourceTypes | Where-Object ResourceTypeName -eq batchAccounts).Locations

它會傳回:Which returns:

West Europe
East US
East US 2
West US
...

Azure CLIAzure CLI

若要查看 Azure 中的所有資源提供者,以及您訂用帳戶的登錄狀態,請使用:To see all resource providers in Azure, and the registration status for your subscription, use:

az provider list --query "[].{Provider:namespace, Status:registrationState}" --out table

傳回的結果類似於:Which returns results similar to:

Provider                         Status
-------------------------------- ----------------
Microsoft.ClassicCompute         Registered
Microsoft.ClassicNetwork         Registered
Microsoft.ClassicStorage         Registered
Microsoft.CognitiveServices      Registered
...

若要註冊資源提供者,請使用:To register a resource provider, use:

az provider register --namespace Microsoft.Batch

它會傳回一則訊息說明註冊持續進行中。Which returns a message that registration is on-going.

若要查看特定資源提供者的資訊,請使用:To see information for a particular resource provider, use:

az provider show --namespace Microsoft.Batch

傳回的結果類似於:Which returns results similar to:

{
    "id": "/subscriptions/####-####/providers/Microsoft.Batch",
    "namespace": "Microsoft.Batch",
    "registrationsState": "Registering",
    "resourceTypes:" [
        ...
    ]
}

若要查看資源提供者的資源類型,請使用:To see the resource types for a resource provider, use:

az provider show --namespace Microsoft.Batch --query "resourceTypes[*].resourceType" --out table

它會傳回:Which returns:

Result
---------------
batchAccounts
operations
locations
locations/quotas

API 版本會對應至資源提供者所發行的 REST API 作業版本。The API version corresponds to a version of REST API operations that are released by the resource provider. 當資源提供者啟用新功能時,它會發行新版本的 REST API。As a resource provider enables new features, it releases a new version of the REST API.

若要取得資源類型的可用 API 版本,請使用:To get the available API versions for a resource type, use:

az provider show --namespace Microsoft.Batch --query "resourceTypes[?resourceType=='batchAccounts'].apiVersions | [0]" --out table

它會傳回:Which returns:

Result
---------------
2017-05-01
2017-01-01
2015-12-01
2015-09-01
2015-07-01

所有區域都支援資源管理員,但您部署的資源可能無法在所有區域中受到支援。Resource Manager is supported in all regions, but the resources you deploy might not be supported in all regions. 此外,您的訂用帳戶可能會有限制,以防止您使用某些支援該資源的區域。Also, there may be limitations on your subscription that prevent you from using some regions that support the resource.

若要取得資源類型支援的位置,請使用:To get the supported locations for a resource type, use.

az provider show --namespace Microsoft.Batch --query "resourceTypes[?resourceType=='batchAccounts'].locations | [0]" --out table

它會傳回:Which returns:

Result
---------------
West Europe
East US
East US 2
West US
...

後續步驟Next steps