Events
17 Mar, 9 pm - 21 Mar, 10 am
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
APPLIES TO: All API Management tiers
There are times when it's impractical to have all callers to your API use exactly the same version. When callers want to upgrade to a later version, they want an approach that's easy to understand. As shown in this tutorial, it's possible to provide multiple versions in Azure API Management.
For background, see Versions & Revisions.
Tip
API teams can use this feature in workspaces. Workspaces provide isolated administrative access to APIs and their own API runtime environments.
In this tutorial, you learn how to:
Tip
Versions can also be enabled when you create a new API. On the Add API screen, select Version this API?.
In Azure API Management, you choose how callers specify the API version by selecting a versioning scheme: path, header, or query string. In the following example, path is used as the versioning scheme.
Enter the values from the following table. Then select Create to create your version.
Setting | Value | Description |
---|---|---|
Version identifier | v1 | Scheme-specific indicator of the version. For Path, the suffix for the API URL path. |
Versioning scheme | Path | The way callers specify the API version. If Header or Query string is selected, enter another value: the name of the header or query string parameter. A usage example is displayed. |
Full API version name | swagger-petstore-v1 | Unique name in your API Management instance. Because a version is in fact a new API based off an API's revision, this setting is the new API's name. |
Products | Unlimited (provided in certain service tiers) | Optionally, one or more products that the API version is associated with. To publish the API, you must associate it with a product. You can also add the version to a product later. |
After creating the version, it now appears underneath Swagger Petstore in the API List. You now see two APIs: Original, and v1.
Note
If you add a version to a non-versioned API, an Original is also automatically created. This version responds on the default URL. Creating an Original version ensures that any existing callers are not broken by the process of adding a version. If you create a new API with versions enabled at the start, an Original isn't created.
After adding the version, you can now edit and configure it as an API that is separate from an Original. Changes to one version don't affect another. For example, add or remove API operations, or edit the OpenAPI specification. For more information, see Edit an API.
In order for callers to see the new version, it must be added to a product. If you didn't already add the version to a product, you can add it to a product at any time.
For example, to add the version to the Unlimited product:
When you create multiple versions, the Azure portal creates a version set, which represents a set of versions for a single logical API. Select the name of an API that has multiple versions. The Azure portal displays its Version set. You can customize the Name and Description of a virtual set.
You can interact directly with version sets by using the Azure CLI:
Use the Bash environment in Azure Cloud Shell. For more information, see Quickstart for Bash in Azure Cloud Shell.
If you prefer to run CLI reference commands locally, install the Azure CLI. If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI.
When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see Use extensions with the Azure CLI.
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
To see all your version sets, run the az apim api versionset list command:
az apim api versionset list --resource-group apim-hello-world-resource-group \
--service-name apim-hello-world --output table
When the Azure portal creates a version set for you, it assigns an alphanumeric name, which appears in the Name column of the list. Use this name in other Azure CLI commands.
To see details about a version set, run the az apim api versionset show command:
az apim api versionset show --resource-group apim-hello-world-resource-group \
--service-name apim-hello-world --version-set-id 00000000000000000000000
For more information about version sets, see Versions in Azure API Management.
If you've tried the developer portal, you can see API versions there.
In this tutorial, you learned how to:
Advance to the next tutorial:
Events
17 Mar, 9 pm - 21 Mar, 10 am
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Publish and manage your APIs with Azure API Management - Training
Learn about using an Azure API gateway to share APIs with partners, and how to use subscription keys to control access to your APIs.
Certification
Microsoft Certified: Azure Virtual Desktop Specialty - Certifications
Plan, deliver, manage, and monitor virtual desktop experiences and remote apps on Microsoft Azure for any device.