你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Set-AzApiManagement

汇报 Azure Api 管理服务

语法

Set-AzApiManagement
   -InputObject <PsApiManagement>
   [-SystemAssignedIdentity]
   [-UserAssignedIdentity <String[]>]
   [-AsJob]
   [-PassThru]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

说明

Set-AzApiManagement cmdlet 更新 Azure API 管理服务。

示例

示例 1:获取API 管理服务并将其缩放为“高级”并添加区域

$apim = Get-AzApiManagement -ResourceGroupName "ContosoGroup" -Name "ContosoApi"
$apim.Sku = "Premium"
$apim.Capacity = 5
$apim.AddRegion("Central US", "Premium", 3)
Set-AzApiManagement -InputObject $apim

此示例获取 Api 管理实例,将其缩放为五个高级单元,然后将额外的三个单元添加到高级区域。

示例 2:更新部署 (外部 VNET)

$virtualNetwork = New-AzApiManagementVirtualNetwork -SubnetResourceId "/subscriptions/a8ff56dc-3bc7-4174-a1e8-3726ab15d0e2/resourceGroups/Api-Default-WestUS/providers/Microsoft.Network/virtualNetworks/dfVirtualNetwork/subnets/backendSubnet"
$apim = Get-AzApiManagement -ResourceGroupName "ContosoGroup" -Name "ContosoApi"
$apim.VpnType = "External"
$apim.VirtualNetwork = $virtualNetwork
Set-AzApiManagement -InputObject $apim

此命令将更新现有的API 管理部署并加入外部 VpnType

示例 3:使用 KeyVault 资源中的机密创建和初始化 PsApiManagementCustomHostNameConfiguration 实例

$portal = New-AzApiManagementCustomHostnameConfiguration -Hostname "portal.contoso.com" -HostnameType Portal -KeyVaultId "https://apim-test-keyvault.vault.azure.net/secrets/api-portal-custom-ssl.pfx"
$proxy1 = New-AzApiManagementCustomHostnameConfiguration -Hostname "gatewayl.contoso.com" -HostnameType Proxy -KeyVaultId "https://apim-test-keyvault.vault.azure.net/secrets/contoso-proxy-custom-ssl.pfx"
$proxy2 = New-AzApiManagementCustomHostnameConfiguration -Hostname "gatewayl.foobar.com" -HostnameType Proxy -KeyVaultId "https://apim-test-keyvault.vault.azure.net/secrets/foobar-proxy-custom-ssl.pfx"
$proxyCustomConfig = @($proxy1,$proxy2)
$apim = Get-AzApiManagement -ResourceGroupName "ContosoGroup" -Name "ContosoApi"
$apim.PortalCustomHostnameConfiguration = $portal
$apim.ProxyCustomHostnameConfiguration = $proxyCustomConfig 
Set-AzApiManagement -InputObject $apim -SystemAssignedIdentity

示例 4:更新发布服务器Email、NotificationSender Email 和组织名称

$apim = Get-AzApiManagement -ResourceGroupName "api-Default-West-US" -Name "Contoso"
$apim.PublisherEmail = "foobar@contoso.com"
$apim.NotificationSenderEmail = "notification@contoso.com"
$apim.OrganizationName = "Contoso"
Set-AzApiManagement -InputObject $apim -PassThru

示例 5:将托管证书添加到 APIM 服务

$gateway=New-AzApiManagementCustomHostnameConfiguration -Hostname freecertCanary.contoso.api -HostnameType Proxy -ManagedCertificate
$customConfig= @($gateway)
$apim=Get-AzApiManagement -ResourceGroupName contosogroup -Name contosoapim
$apim.ProxyCustomHostnameConfiguration = $customConfig
Set-AzApiManagement -InputObject $apim -PassThru


PublicIPAddresses                     : {20.45.236.81}
PrivateIPAddresses                    :
Id                                    : /subscriptions/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/Api-Default-
                                        Central-US-EUAP/providers/Microsoft.ApiManagement/service/contosoapim
Name                                  : contosoapim
Location                              : Central US EUAP
Sku                                   : Developer
Capacity                              : 1
CreatedTimeUtc                        : 8/24/2021 10:40:21 PM
ProvisioningState                     : Succeeded
RuntimeUrl                            : https://contosoapim.azure-api.net
RuntimeRegionalUrl                    : https://contosoapim-centraluseuap-01.regional.azure-api.net
PortalUrl                             : https://contosoapim.portal.azure-api.net
DeveloperPortalUrl                    : https://contosoapim.developer.azure-api.net
ManagementApiUrl                      : https://contosoapim.management.azure-api.net
ScmUrl                                : https://contosoapim.scm.azure-api.net
PublisherEmail                        : zhonren@microsoft.com
OrganizationName                      : Microsoft
NotificationSenderEmail               : apimgmt-noreply@mail.windowsazure.com
VirtualNetwork                        :
VpnType                               : None
PortalCustomHostnameConfiguration     :
ProxyCustomHostnameConfiguration      : {contosoapim.azure-api.net, freecertCanary..contoso.api}
ManagementCustomHostnameConfiguration :
ScmCustomHostnameConfiguration        :
DeveloperPortalHostnameConfiguration  :
SystemCertificates                    :
Tags                                  : {}
AdditionalRegions                     : {}
SslSetting                            : Microsoft.Azure.Commands.ApiManagement.Models.PsApiManagementSslSetting
Identity                              : Microsoft.Azure.Commands.ApiManagement.Models.PsApiManagementServiceIdentity
EnableClientCertificate               :
Zone                                  :
DisableGateway                        : False
MinimalControlPlaneApiVersion         :
PublicIpAddressId                     :
PlatformVersion                       : stv2
PublicNetworkAccess                   : Enabled
PrivateEndpointConnections            :
ResourceGroupName                     : contosogroup

$apim.ProxyCustomHostnameConfiguration

CertificateInformation     :
EncodedCertificate         :
HostnameType               : Proxy
CertificatePassword        :
Hostname                   : contosoapim.azure-api.net
KeyVaultId                 :
DefaultSslBinding          : False
NegotiateClientCertificate : False
IdentityClientId           :
CertificateStatus          :
CertificateSource          : BuiltIn

CertificateInformation     : Microsoft.Azure.Commands.ApiManagement.Models.PsApiManagementCertificateInformation
EncodedCertificate         :
HostnameType               : Proxy
CertificatePassword        :
Hostname                   : freecertCanary.contoso.api
KeyVaultId                 :
DefaultSslBinding          : True
NegotiateClientCertificate : False
IdentityClientId           :
CertificateStatus          :
CertificateSource          : Managed

此示例将托管证书添加到API 管理服务。

参数

-AsJob

在后台运行 cmdlet

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

提示你在运行 cmdlet 之前进行确认。

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

ApiManagement 实例。

Type:PsApiManagement
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-PassThru

如果操作成功,将更新的 PsApiManagement 发送到管道。

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-SystemAssignedIdentity

为此服务器生成并分配 Azure Active Directory 标识,以便与 Azure KeyVault 等密钥管理服务一起使用。

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-UserAssignedIdentity

将用户标识分配给此服务器,以便与 Azure KeyVault 等密钥管理服务一起使用。

Type:String[]
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

显示在此 cmdlet 运行的情况下将会发生什么。 此 cmdlet 未运行。

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

输入

PsApiManagement

输出

PsApiManagement