API Management - make a revision current

2024-05-09T18:58:55.2466667+00:00

Using this API: https://learn.microsoft.com/en-us/rest/api/apimanagement/apis/update?view=rest-apimanagement-2022-08-01&tabs=HTTP
I'm trying to promote revision rev2 as Current

Powershell example


$jsonBody = @{

 properties = @{

   description = "xxxxx133"

   isCurrent = $true

 }

}

$responseX32 = Invoke-WebRequest -Uri "https://management.azure.com/subscriptions/$sub/resourceGroups/$rg/providers/Microsoft.ApiManagement/service/$($apim)/apis/OVA-CR-XXXX-API-INT-v1%3Brev%3D2?api-version=2023-05-01-preview" `

  -Method Patch `

  -Headers $headers `

  -Body ($jsonBody | ConvertTo-Json) 

Write-Host $responseX32

I'm able to change the description but isCurrent is still true for rev1 and not for rev2


  "id": "/subscriptions/xxxxxx/resourceGroups/xxxx/providers/Microsoft.ApiManagement/service/xxxxxxx/apis/OVA-CR-XXXX-API-INT-v1;rev=2",

  "type": "Microsoft.ApiManagement/service/apis",

  "name": "OVA-CR-XXXX-API-INT-v1;rev=2",

  "properties": {

    "displayName": "OVA-CR-XXXX-API-INT-v1",

    "apiRevision": "2",

    "description": "xxxxx133",

    "subscriptionRequired": false,

    "serviceUrl": "http://sss.com",

    "backendId": null,

    "path": "int/ova/cr/us038/v1",

    "protocols": [

      "http"

    ],

    "authenticationSettings": {

      "oAuth2": null,

      "openid": null

    },

    "subscriptionKeyParameterNames": {

      "header": "Ocp-Apim-Subscription-Key",

      "query": "subscription-key"

    }

  }

}```  
Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,219 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 29,191 Reputation points
    2024-05-14T17:34:15.25+00:00

    @Riccardo Russo (MSC Technology Italia) Thanks for reaching out. When you create a revision for an api it is considered as a new api and inorder to make it as current you need to create an API release

    https://learn.microsoft.com/en-us/rest/api/apimanagement/api-release/create-or-update?view=rest-apimanagement-2022-08-01&tabs=HTTP#code-try-0

    {
      "properties": {
    "apiId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/{apiId}",
      }
    }
    

    Once after creating a new release then you will be able to make a revision as current

    PATCH [https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}?api-version=2022-08-01]()
    json
    {
      "properties": {
         "apiRevision": "2",
         "isCurrent": true,
        "isOnline": true
      }
    }
    
    {
      "id": "/subscriptions/xx/resourceGroups/xx/providers/Microsoft.ApiManagement/service/xxx/apis/swagger-petstore",
      "type": "Microsoft.ApiManagement/service/apis",
      "name": "swagger-petstore",
      "properties": {
        "displayName": "Swagger Petstore",
        "apiRevision": "2",
        "description": "janani",
        "subscriptionRequired": true,
        "serviceUrl": "https://new-cxp-apim.azure-api.net/",
        "backendId": null,
        "path": "testingopenapi",
        "protocols": [
          "http",
          "https"
        ],
        "authenticationSettings": {
          "oAuth2": null,
          "openid": null
        },
        "subscriptionKeyParameterNames": {
          "header": "Ocp-Apim-Subscription-Key",
          "query": "subscription-key"
        },
        "termsOfServiceUrl": "http://swagger.io/terms/",
        "contact": {
          "name": null,
          "url": null,
          "email": "apiteam@swagger.io"
        },
        "license": {
          "name": "Apache 2.0",
          "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
        },
        "isCurrent": true,
        "apiRevisionDescription": "janani"
      }
    }
    
    
    

    do let me know incase of further queries, I would be happy to assist you.

    refer: https://learn.microsoft.com/en-us/azure/api-management/api-management-revisions#current-revision

    Please accept as Yes if the answer provided is useful, so that you can help others in the community looking for remediation for similar issues.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.