Home > Net >  Use same subscription key for APIM instances in Azure
Use same subscription key for APIM instances in Azure

Time:10-23

we are using APIM premium version and ours is a active-active multi region setup. The problem we are facing is when one region UI calls another region API the calls failing because the subscription keys for the APIM on the both the region is different. is there a way I can set the subscription key for default subscription for the scope "service". I have tried the below powershell command from here but the second command fails saying the resource group not found, though from the first command its able to pull the details.

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

also I have checked this question, but the link in the answer shows 404.

Instead of resetting the APIM subscription keys is there anyother best practices that we can follow for these kind of scenarios ?

CodePudding user response:

This 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 and uses Postman to update the keys via a REST call.

CodePudding user response:

while @NadineRaiss answer solves the problem. I would like to add the issue what I have faced with powershell. I have set the context in az cli, az account set but if we are using powershell we need to set the context using set-azcontext for setting the powershell context. once I set that and ran the command, I am able to achieve what I wanted.

also, with this method we cannot update global subscription(master), we can only set the custom created product subscription.

  • Related