skip to Main Content

After uptdating apim from stv1 to stv2 i’m not able remove region via powershell with this command:

Get-AzApiManagement -ResourceGroupName $APIMresourceGroupName -Name $APIMaccountName | Remove-AzApiManagementRegion -Location "North Europe" | Set-AzApiManagement

it worked until there was v1. Now I got following error:

Set-AzApiManagement: ‘SubnetResourceId’ does not match expected pattern ‘^/subscriptions/[^/]/resourceGroups/[^/]/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]/subnets/[^/]$’.

If i just run

Get-AzApiManagement -ResourceGroupName $APIMresourceGroupName -Name $APIMaccountName | Remove-AzApiManagementRegion -Location "North Europe"

the region is removed from the object, but if i se the modify with set-azapimanagent i got error written before.

I’m using latest cmdlet api.management. There is someone that have same problem?

Thanks

2

Answers


  1. Chosen as BEST ANSWER

    I found the resolution here https://github.com/Azure/azure-powershell/issues/22565 :

    ### CHANGE SKU
    $apimSKU = Get-AzApiManagement -ResourceGroupName $APIMresourceGroupName -Name $APIMaccountName
    $apimSKU.VirtualNetwork.SubnetResourceId = $apimSKU.VirtualNetwork.SubnetResourceId -replace "microsoft.network", "Microsoft.Network" -replace "resourcegroups", "resourceGroups" -replace "virtualnetworks", "virtualNetworks"
    $apimSKU.Sku = "Developer"
    
    Set-AzApiManagement -InputObject $apimSKU
    

    above a small example. Basically with migration to v2 the $apimSKU.VirtualNetwork.SubnetResourceId is in lowercase and Set-AzApiManagement does not manage it.

    Regards


  2. If you are trying to remove the secondary location from APIM resource stv2.1 platform version then below command should work for you as it worked for me.

    Get-AzApiManagement -ResourceGroupName $APIMresourceGroupName -Name $APIMaccountName | Remove-AzApiManagementRegion -Location "East US" | Set-AzApiManagement
    

    enter image description here

    Post executing this command, my apim instance got updated as shown below.

    enter image description here

    Please review your command as the error you are getting is related to subnet.

    For Premium tier

    I have enabled internal vnet in APIM instance and executed same command successfully which removed the secondary location.

    enter image description here

    enter image description here

    I had these two locations-

    enter image description here

    Once the APIM instance gets updated successfully you won’t be able to see Service is being updated message and then secondary location will get removed.

    enter image description here

    Please make sure to execute the command when the service is not in update state.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search