Skip to content

Commit a327f86

Browse files
committed
wip
1 parent c1fcd39 commit a327f86

File tree

2 files changed

+76
-9
lines changed

2 files changed

+76
-9
lines changed

articles/api-center/import-api-management-apis.md

Lines changed: 75 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ ms.custom: devx-track-azurecli
1414

1515
This article shows how to import (add) APIs from an Azure API Management instance to your [API center](overview.md) using the Azure CLI. Adding APIs from API Management to your API inventory helps make them discoverable and accessible to developers, API program managers, and other stakeholders in your organization.
1616

17-
When you add an API from an API Management instance to your API center:
17+
This article shows two options for using the Azure CLI to add APIs to your API center from API Management:
18+
19+
* Export an API from API Management to an API definition using the [az apim api export](/cli/azure/apim/api#az-apim-api-export) command. Then, run [az apic api register](/cli/azure/apic/api#az-apic-api-register) to register the API in your API center, using the API definition.
20+
21+
* Bulk-import APIs from API Management to your API center using the [az apic service import-from-apim](/cli/azure/apic/service#az-apic-service-import-from-apim) command.
22+
23+
When you add an API from an API Management instance to your API center using the bulk-import option, the following happens automatically:
1824

1925
* The API's [versions](key-concepts.md#api-version), [definitions](key-concepts.md#api-definition), and [deployment](key-concepts.md#deployment) information are copied to your API center.
2026
* The API receives a system-generated API name in your API center. It retains its display name (title) from API Management.
@@ -44,12 +50,72 @@ After adding an API from API Management, you can add metadata and documentation
4450
> [!NOTE]
4551
> Azure CLI command examples in this article can run in PowerShell or a bash shell. Where needed because of different variable syntax, separate command examples are provided for the two shells.
4652
53+
## Option 1: Export an API from API Management and register it in your API center
54+
55+
First, export an API from your API Management instance to an API definition using the [az apim api export](/cli/azure/apim/api#az-apim-api-export) command. For example:
56+
57+
58+
### Export API to a local API definition file
59+
60+
The following example exports the API with identifier *my-api* in the *myAPIManagement* instance of API. The API is exported in OpenApiJson format to a local OpenAPI definition file named *specificationFile.json*.
61+
62+
```azurecli-interactive
63+
#! /bin/bash
64+
az apim api export --api-id my-api --resource-group myResourceGroup \
65+
--service-name myAPIManagement --export-format OpenApiJsonFile \
66+
--file-path /path/to/folder
67+
```
68+
69+
### Export API to a URL
70+
71+
The following example exports the API with identifier *my-api* in the *myAPIManagement* instance of API. The API is exported in OpenApiJson format to a URL in Azure storage. The URL is available for approximately 5 minutes.
72+
73+
```azurecli-interactive
74+
link=$(az apim api export --api-id my-api --resource-group myResourceGroup \
75+
--service-name myAPIManagement --export-format OpenApiJsonUrl --query properties.value.link --output tsv)
76+
```
77+
78+
The URL appears in the command output. You can use the link to download the API definition file.
79+
80+
```output
81+
[...]
82+
"name": "my-api",
83+
"properties": {
84+
"format": "openapi+json-link",
85+
"value": {
86+
"link": "https://xxxxxxxxxxxxxxxxx.blob.core.windows.net/api-export/My API......."
87+
[...]
88+
}
89+
}
90+
91+
```
92+
93+
### Import local API definition to your API center
94+
95+
Then, use the [az apic api register](/cli/azure/apic/api#az-apic-api-register) command to register the API in your API center, using the API definition.
96+
97+
The following example registers an API in the *myAPICenter* API center from a local OpenAPI definition file named *definitionFile.json*.
98+
99+
```azurecli-interactive
100+
az apic api register --resource-group myResourceGroup \
101+
--service myAPICenter --api-location "/Path/to/definitionFile.json
102+
```
103+
104+
### Import API definition from a URL to your API center
105+
106+
The following example registers an API in the *myAPICenter* API center from an OpenAPI definition file at a URL whose value is stored in the *$link* variable.
107+
108+
```azurecli-interactive
109+
110+
```
111+
112+
## Option 2: Bulk-import APIs from your API Management instance
47113

48-
## Add a managed identity in your API center
114+
### Add a managed identity in your API center
49115

50116
For this scenario, your API center uses a [managed identity](/entra/identity/managed-identities-azure-resources/overview) to access APIs in your API Management instance. You can use either a system-assigned or user-assigned managed identity. If you haven't added a managed identity in your API center, you can add it in the Azure portal or by using the Azure CLI.
51117

52-
### Add a system-assigned identity
118+
#### Add a system-assigned identity
53119

54120
#### [Portal](#tab/portal)
55121

@@ -67,7 +133,7 @@ az apic service update --name <api-center-name> --resource-group <resource-group
67133
```
68134
---
69135

70-
### Add a user-assigned identity
136+
#### Add a user-assigned identity
71137

72138
To add a user-assigned identity, you need to create a user-assigned identity resource, and then add it to your API center.
73139

@@ -115,7 +181,7 @@ To add a user-assigned identity, you need to create a user-assigned identity res
115181
```
116182
---
117183
118-
## Assign the managed identity the API Management Service Reader role
184+
### Assign the managed identity the API Management Service Reader role
119185
120186
To allow import of APIs, assign your API center's managed identity the **API Management Service Reader** role in your API Management instance. You can use the [portal](../role-based-access-control/role-assignments-portal-managed-identity.md) or the Azure CLI.
121187
@@ -195,7 +261,7 @@ To allow import of APIs, assign your API center's managed identity the **API Man
195261
--scope $scope
196262
---
197263
198-
## Import APIs from your API Management instance
264+
### Bulk-import APIs from your API Management instance
199265
200266
Use the [az apic service import-from-apim](/cli/azure/apic/service#az-apic-service-import-from-apim) command to import one or more APIs from your API Management instance to your API center.
201267
@@ -204,7 +270,7 @@ Use the [az apic service import-from-apim](/cli/azure/apic/service#az-apic-servi
204270
>
205271
> * If your API center has multiple managed identities, the command searches first for a system-assigned identity. If none is found, it picks the first user-assigned identity in the list.
206272
207-
### Import all APIs from an API Management instance
273+
#### Import all APIs from an API Management instance
208274
209275
Use a wildcard (`*`) to specify all APIs from the API Management instance.
210276
@@ -229,7 +295,7 @@ Use a wildcard (`*`) to specify all APIs from the API Management instance.
229295
> [!NOTE]
230296
> If your API Management instance has a large number of APIs, import to your API center might take some time.
231297
232-
### Import a specific API from an API Management instance
298+
#### Import a specific API from an API Management instance
233299
234300
Specify an API to import using its name from the API Management instance.
235301
@@ -259,6 +325,7 @@ After importing APIs from API Management, you can view and manage the imported A
259325
## Related content
260326
261327
* [Azure CLI reference for API Center](/cli/azure/apic)
328+
* [Azure CLI reference for API Management](/cli/azure/apim)
262329
* [Manage API inventory with Azure CLI commands](manage-apis-azure-cli.md)
263330
* [Assign Azure roles to a managed identity](../role-based-access-control/role-assignments-portal-managed-identity.md)
264331
* [Azure API Management documentation](../api-management/index.yml)

articles/api-center/register-apis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ To add an API definition to your version:
120120
| **Description** | Optionally enter a description. | Description of the API definition. |
121121
| **Specification name** | For the Demo Conference API, select **OpenAPI**. | Specification format for the API.|
122122
| **Specification version** | Enter a version identifier of your choice, such as *2.0*. | Specification version. |
123-
|**Document** | Browse to a definition file for the Demo Conference API. | API definition file. |
123+
|**Document** | Browse to a definition file for the Demo Conference API, or enter a URL. | API definition file. |
124124

125125
:::image type="content" source="media/register-apis/add-definition.png" alt-text="Screenshot of adding an API definition in the portal." lightbox="media/register-apis/add-definition.png" :::
126126

0 commit comments

Comments
 (0)