skip to Main Content

I try to create a subscription in Azure APIM with:

New-AzApiManagementSubscription -Context $Context  -Name "test-01"    -Scope "/products/test-ericf" -Verbose

but always receive error message:

New-AzApiManagementSubscription: 
Error Code: ValidationError
Error Message: One or more fields contain incorrect values:
Request Id: 7fc113c3-83af-4c6d-9e50-6825aefb3817
Error Details:
        [Code= ValidationError, Message= Invalid field 'ownerId' specified, Target= ownerId]

Any ideas?

I also tried with -debug, and got the error:

New-AzApiManagementSubscription: 
Error Code: ValidationError
Error Message: One or more fields contain incorrect values:
Request Id: c6a6e092-66ac-4886-9569-d9a6c8e7cb17
Error Details:
        [Code= ValidationError, Message= Invalid field 'ownerId' specified, Target= 

2

Answers


  1. Invalid owner id occurs when you want to associate a subscription to the specific user under APIM. To avoid this kind of issues, retrieve the assigned users from APIM in the below format first.

    $Context = New-AzApiManagementContext -ResourceGroupName "Jahnavi" -ServiceName "newapimjah"
    Get-AzApiManagementUser -Context $Context
    

    enter image description here

    Take the respective userId from it and assign the subscription to the user as shown below.

    New-AzApiManagementSubscription -Context $Context -Scope "/products/sampleprod" -Name "newsubsc" -UserId 1
    

    enter image description here

    Alternatively, I have also tried with the default starter product without any user related information, and it worked as expected.

    $Context = New-AzApiManagementContext -ResourceGroupName "Jahnavi" -ServiceName "newapimjah"
    New-AzApiManagementSubscription -Context $Context -Scope "/products/starter" -Name "newsubsc"
    

    enter image description here

    Reference: MSDoc

    Login or Signup to reply.
  2. Thanks a lot

    I will try that .

    Which version of PS do you use ?

    I use powershell 7.4

    Regards

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