本文演示如何管理 Azure 订阅中的预览功能。 借助预览功能,你可以在发布前便选择使用新功能。 有意向选择加入的任何用户都可以使用部分预览功能。 其他预览功能则需要获得产品团队的批准。
可通过 Microsoft.Features 命名空间获取 Azure 功能公开控件 (AFEC)。 预览功能的资源 ID 格式如下:
Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}
所需访问权限
若要在 Azure 订阅中列出、注册或取消注册预览功能,需要对 Microsoft.Features/* 操作的访问权限。 此权限是通过参与者和所有者内置角色授予的。 还可以通过自定义角色指定所需的访问权限。
列出预览功能
可以列出 Azure 订阅的所有预览功能及其注册状态。
登录到 Azure 门户。
 
在搜索框中,输入“订阅” , 然后选择“订阅”。
              
              
              
              
            
 
选择订阅名称的链接。
              
              
              
              
            
 
从左侧菜单的“设置”下,选择“预览功能”。
              
              
              
              
            
 
你会看到包含可用预览功能和当前注册状态的列表。
              
              
              
              
            
 
在“预览功能”中,可以按“名称”、“状态”或“类型”筛选列表:
- 按名称筛选:必须包含预览功能名称而不是显示名称中的文本。
 
- 状态:选择下拉菜单并选择状态。 门户不会按“已注销”进行筛选。
 
- 类型:选择下拉菜单并选择类型。
 
              
              
              
              
            
 
若要列出订阅的所有预览功能,请使用 az feature list 命令。
Azure CLI 的默认输出为 JSON。 有关其他输出格式的详细信息,请参阅 Azure CLI 命令的输出格式。
az feature list
{
  "id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/providers/Microsoft.Features/providers/
    Microsoft.Compute/features/InGuestPatchVMPreview",
  "name": "Microsoft.Compute/InGuestPatchVMPreview",
  "properties": {
    "state": "NotRegistered"
  },
  "type": "Microsoft.Features/providers/features"
}
若要筛选特定资源提供程序的输出,请使用 namespace 参数。 此示例中,output 参数将指定表格式。
az feature list --namespace Microsoft.Compute --output table
Name                                                RegistrationState
-------------------------------------------------   -------------------
Microsoft.Compute/AHUB                              Unregistered
Microsoft.Compute/AllowManagedDisksReplaceOSDisk    Registered
Microsoft.Compute/AllowPreReleaseRegions            Pending
Microsoft.Compute/InGuestPatchVMPreview             NotRegistered
若要筛选特定预览功能的输出,请使用 az feature show 命令。
az feature show --name InGuestPatchVMPreview --namespace Microsoft.Compute --output table
Name                                     RegistrationState
---------------------------------------  -------------------
Microsoft.Compute/InGuestPatchVMPreview  NotRegistered
若要列出订阅的所有预览功能,请使用 Get-AzProviderFeature 命令。
Get-AzProviderFeature -ListAvailable
FeatureName      ProviderName     RegistrationState
-----------      ------------     -----------------
betaAccess       Microsoft.AAD    NotRegistered
previewAccess    Microsoft.AAD    Registered
tipAccess        Microsoft.AAD    Pending
testAccess       Microsoft.AAD    Unregistered
若要筛选特定资源提供程序的输出,请使用 ProviderNamespace 参数。 默认输出仅会显示已注册的功能。 若要显示资源提供程序的所有预览功能,请配合使用 ListAvailable 参数与 ProviderNamespace 参数。
Get-AzProviderFeature -ProviderNamespace "Microsoft.Compute" -ListAvailable
FeatureName                          ProviderName        RegistrationState
-----------                          ------------        -----------------
AHUB                                 Microsoft.Compute   Unregistered
AllowManagedDisksReplaceOSDisk       Microsoft.Compute   Registered
AllowPreReleaseRegions               Microsoft.Compute   Pending
InGuestPatchVMPreview                Microsoft.Compute   NotRegistered
可以使用 FeatureName 参数筛选特定预览功能的输出。
Get-AzProviderFeature -FeatureName "InGuestPatchVMPreview" -ProviderNamespace "Microsoft.Compute"
FeatureName             ProviderName        RegistrationState
-----------             ------------        -----------------
InGuestPatchVMPreview   Microsoft.Compute   NotRegistered
 
注册预览功能
若要公开资源提供程序的更多功能,可以在 Azure 订阅中注册预览功能。 部分预览功能需要审批。
在订阅中注册预览功能后,你将看到以下两种状态之一:“已注册”或“待处理”。
- 对于无需审批的预览功能,状态则为“已注册”。
 
- 如果预览功能需要审批,则注册状态为“待处理”。 必须从提供预览功能的 Azure 服务请求批准。 通常,可以通过支持工单请求访问权限。
 
某些服务需要其他方法(如电子邮件)才能获得对待处理请求的批准。 查看有关预览功能的公告,了解有关如何获取访问权限的信息。
登录到 Azure 门户。
 
在搜索框中,输入“订阅” , 然后选择“订阅”。
 
选择订阅名称的链接。
 
从左侧菜单的“设置”下,选择“预览功能” 。
 
选择要注册的预览功能的链接。
 
选择“注册”。
              
              
              
              
            
 
选择“确定”。
 
预览功能屏幕将刷新,预览功能的状态也会显示。
若要注册预览功能,请使用 az feature register 命令。
az feature register --name InGuestPatchVMPreview --namespace Microsoft.Compute
{
  "id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/providers/Microsoft.Features/providers/
    Microsoft.Compute/features/InGuestPatchVMPreview",
  "name": "Microsoft.Compute/InGuestPatchVMPreview",
  "properties": {
    "state": "Registering"
  },
  "type": "Microsoft.Features/providers/features"
}
若要查看注册状态,请使用 az feature show 命令。
az feature show --name InGuestPatchVMPreview --namespace Microsoft.Compute --output table
Name                                     RegistrationState
---------------------------------------  -------------------
Microsoft.Compute/InGuestPatchVMPreview  Registered
注意
当运行注册命令时,会返回一条消息,其中建议在注册该功能后运行 az provider register --namespace <provider-name> 以传播更改。
 
若要注册预览功能,请使用 Register-AzProviderFeature cmdlet。
Register-AzProviderFeature -FeatureName "InGuestPatchVMPreview" -ProviderNamespace "Microsoft.Compute"
FeatureName             ProviderName        RegistrationState
-----------             ------------        -----------------
InGuestPatchVMPreview   Microsoft.Compute   Registering
若要查看注册状态,请使用 Get-AzProviderFeature cmdlet。
Get-AzProviderFeature -FeatureName "InGuestPatchVMPreview" -ProviderNamespace "Microsoft.Compute"
FeatureName             ProviderName        RegistrationState
-----------             ------------        -----------------
InGuestPatchVMPreview   Microsoft.Compute   Registered
 
注销预览功能
使用完预览功能后,请从 Azure 订阅中注销该功能。 注销此功能后,你可能会注意到两种不同的状态。 如果通过门户注销,状态将变成“未注册”。 如果通过 Azure CLI、PowerShell 或 REST API 注销,则状态将变为“已注销”。 状态存在差异的原因在于,门户会删除功能注册,但命令则会取消注册该功能。 在这两种情况下,该功能在订阅中均不再可用, 但可以通过重新注册功能来再次选择使用该功能。
可以从“预览功能”中注销预览功能。 “状态”将更改为“未注册”。
登录到 Azure 门户。
 
在搜索框中,输入“订阅” , 然后选择“订阅”。
 
选择订阅名称的链接。
 
从左侧菜单的“设置”下,选择“预览功能”。
 
选择要注销的预览功能链接。
 
选择“注销”。
              
              
              
              
            
 
选择“确定”。
 
若要注销预览功能,请使用 az feature register 命令。 
              RegistrationState 状态将更改为“已注销”。
az feature unregister --name InGuestPatchVMPreview --namespace Microsoft.Compute
{
  "id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/providers/Microsoft.Features/providers/
    Microsoft.Compute/features/InGuestPatchVMPreview",
  "name": "Microsoft.Compute/InGuestPatchVMPreview",
  "properties": {
    "state": "Unregistering"
  },
  "type": "Microsoft.Features/providers/features"
}
若要查看注销状态,请使用 az feature show 命令。
az feature show --name InGuestPatchVMPreview --namespace Microsoft.Compute --output table
Name                                     RegistrationState
---------------------------------------  -------------------
Microsoft.Compute/InGuestPatchVMPreview  Unregistered
注意
当运行注销命令时,会返回一条消息,其中建议在注册该功能后运行 az provider register --namespace <provider-name> 以传播更改。
 
若要查找已注销的预览功能,请使用以下命令。 将 <ResourceProvider.Name> 替换为提供程序名称,例如 Microsoft.Compute。
以下示例显示  资源提供程序的“已注销”预览功能。
az feature list --namespace <ResourceProvider.Name> --query "[?properties.state=='Unregistered'].{Name:name, RegistrationState:properties.state}" --output table
Name                                     RegistrationState
---------------------------------------  -------------------
Microsoft.Compute/InGuestPatchVMPreview  Unregistered
若要注销预览功能,请使用 Unregister-AzProviderFeature cmdlet。 
              RegistrationState 状态将更改为“已注销”。
Unregister-AzProviderFeature -FeatureName "InGuestPatchVMPreview" -ProviderNamespace "Microsoft.Compute"
FeatureName             ProviderName        RegistrationState
-----------             ------------        -----------------
InGuestPatchVMPreview   Microsoft.Compute   Unregistering
若要查看注销状态,请使用 Get-AzProviderFeature cmdlet。
Get-AzProviderFeature -FeatureName "InGuestPatchVMPreview" -ProviderNamespace "Microsoft.Compute"
FeatureName             ProviderName        RegistrationState
-----------             ------------        -----------------
InGuestPatchVMPreview   Microsoft.Compute   Unregistered
以下示例显示  资源提供程序的“已注销”预览功能。
Get-AzProviderFeature  -ProviderNamespace "Microsoft.Compute" -ListAvailable | Where-Object { $_.RegistrationState -eq "Unregistered" }
FeatureName             ProviderName        RegistrationState
-----------             ------------        -----------------
InGuestPatchVMPreview   Microsoft.Compute   Unregistered
 
使用 Azure Policy 配置预览功能
如果尚未使用内置策略定义注册,则可以修正订阅以注册到预览功能。 将新订阅添加到现有租户时,此订阅不会自动注册。
后续步骤