How can I transfer a subscription in API Management from one user to another in Azure PowerShell?

Viewed 138

I want to transfer control on API Management subscriptions from one user to another in case the original user e.g. left the company or changed job roles.

1 Answers

Have email address of source and target user prepared, adapt and use these Azure PowerShell commands:

$ctx = New-AzApiManagementContext -ResourceGroupName {your-resource-group} -ServiceName {your-APIM-service-name}
$from = Get-AzApiManagementUser -Context $ctx -Email "from.user@my-company.com"
$to = Get-AzApiManagementUser -Context $ctx -Email "to.user@my-company.com"
Get-AzApiManagementSubscription -Context $ctx -UserId $from.UserId | ConvertTo-Json | Set-Content ./SubscriptionDump.json
Get-Content .\SubscriptionDump.json | ConvertFrom-Json | %{Set-AzApiManagementSubscription -Context $ctx -SubscriptionId $_.SubscriptionId -UserId $to.UserId}
Related