0

I'm trying to update an existing version in a versionset inside an Azure API Management service with a new specification using Azure CLI.

I know it does support importing it as an API without a versionset:

az apim api import `
  --path "/as" `
  --resource-group "myResourceGroup" `
  --service-name "test-apim" `
  --api-id "test-apim" `
  --specification-format "OpenApiJson" `
  --specification-path "..\swagger.json"

And I also know that you can use the Azure Powershell modules to fetch a version set and use this to upload a new specification:

$apiMgmtContext = New-AzApiManagementContext `
    -ResourceGroupName "myResourceGroup" `
    -ServiceName "test-apim"

$versionSet = Get-AzApiManagementApiVersionSet -Context $apiMgmtContext |          
    Where-Object { $_.DisplayName -eq "my-version-set" } |
        Sort-Object -Property ApiVersionSetId -Descending |
            Select-Object -first 1

Import-AzApiManagementApi `
    -Context $apiMgmtContext `
    -ApiVersionSetId $versionSet.ApiVersionSetId `
    -ServiceUrl "http" `
    -SpecificationFormat "OpenApiJson" `
    -SpecificationPath "..\swagger.json" `
    -Path "/as" `
    -ApiId "test-apim"

But does anyone know if this can be done with the az cli as the powershell modules will eventually become obsolete?

Andries
  • 175
  • 1
  • 9

1 Answers1

0

Looking at the documentation, it supports version set.

You need to use the parameter --api-version-set-id:

az apim api import `
  --path "/as" `
  --resource-group "myResourceGroup" `
  --service-name "test-apim" `
  --api-id "test-apim" `
  --specification-format "OpenApiJson" `
  --specification-path "..\swagger.json" `
  --api-version-set-id "my-version-set-id"

Also there is no indication that Az Powershell will become obsolete for the moment.

Thomas
  • 24,234
  • 6
  • 81
  • 125
  • 1
    Wauw, I totally looked over these settings. I was focusing to much on `az apim api versionset`. Thanks. – Andries Jul 08 '21 at 10:22