When i'm running in my machine the commands
$apimContext = New-AzApiManagementContext -ResourceGroupName "xxxxxxxxxxxxx" -ServiceName "xxxxxxxxx"
Get-AzApiManagementProduct -Context $apimContext -ProductId "xxxxxxxxx"
Get-AzApiManagementSubscription -Context $apimContext -ProductId "xxxxxxxxx"
The result is a subscription object with empty keys
SubscriptionId : xxxxxxxxxxxxxxxx
UserId : 1
OwnerId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxx
xxxx/providers/Microsoft.ApiManagement/service/xxxxx
xxxxx/users/1
ProductId : xxxxxx
Scope : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxx
xxxx/providers/Microsoft.ApiManagement/service/xxxxx
xxxx/products/xxxxxx
Name :
State : Active
CreatedDate : 29/04/2022 15:03:33
StartDate : 29/04/2022 00:00:00
ExpirationDate :
EndDate :
NotificationDate :
PrimaryKey :
SecondaryKey :
StateComment :
AllowTracing : True
Id : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx
xxxxx/providers/Microsoft.ApiManagement/service/xxxxx
xxxx/products/xxxxxx/subscriptions/xxxxxxxxxxxxxxx
ResourceGroupName : xxxxxxxxxxxxxx
ServiceName : xxxxxxxxxxx
As we can see the keys appear empty, but in the documentation examples it provides values. If i go to azure portal with my account i can see the values
Is there something i can do when running in a personal machine or in an azure pipeline so that i can get the key values?
CodePudding user response:
The code result examples conflict with the documentation for Get-AzApiManagementSubscription
The Get-AzApiManagementSubscription cmdlet gets a specified subscription, or all subscriptions, if no subscription is specified. Keys will not be included into result details. To get keys, use Get-AzApiManagementSubscriptionKey.