对 Azure 中的 APIM 实例使用相同的订阅密钥

Use same subscription key for APIM instances in Azure

我们使用的是 APIM 高级版,我们的是主动-主动多区域设置。我们面临的问题是当一个区域 UI 调用另一个区域 API 时调用失败,因为两个区域的 APIM 的订阅密钥不同。有没有一种方法可以为范围“服务”的默认订阅设置订阅密钥。我已经从 here 尝试了下面的 powershell 命令,但是第二个命令失败说找不到资源组,尽管从第一个命令它能够提取详细信息。

$apimContext = New-AzureRmApiManagementContext -ResourceGroupName "<RGName>" -ServiceName "<apimname>"
Set-AzureRmApiManagementSubscription -Context $apimContext -SubscriptionId "<azuresubscriptionid>" -PrimaryKey "<key1>" -SecondaryKey "<key2>" -State "Active" -Scope "Service"

我也检查过这个,但是答案中的link显示404。

除了重置 APIM 订阅密钥之外,还有其他我们可以针对此类情况遵循的最佳实践吗?

article might help you achieve what you want. The user needed to have the same value for the subscription keys between two different environments. In order to do that, he enables the Management API 并使用 Postman 通过 REST 调用更新密钥。

而@NadineRaiss 的回答解决了问题。我想补充一下我在使用 powershell 时遇到的问题。我已经在 az cli 和 az account set 中设置了上下文,但是如果我们使用 powershell,我们需要使用 set-azcontext 来设置上下文以设置 powershell 上下文。一旦我设置了它和 运行 命令,我就能实现我想要的。

此外,使用此方法我们无法更新全局订阅(master),我们只能设置自定义创建的产品订阅。