You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/api-center/import-api-management-apis.md
+75-8Lines changed: 75 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,13 @@ ms.custom: devx-track-azurecli
14
14
15
15
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.
16
16
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:
18
24
19
25
* 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.
20
26
* 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
44
50
> [!NOTE]
45
51
> 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.
46
52
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 \
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 \
### 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 \
### 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
47
113
48
-
## Add a managed identity in your API center
114
+
###Add a managed identity in your API center
49
115
50
116
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.
51
117
52
-
### Add a system-assigned identity
118
+
####Add a system-assigned identity
53
119
54
120
#### [Portal](#tab/portal)
55
121
@@ -67,7 +133,7 @@ az apic service update --name <api-center-name> --resource-group <resource-group
67
133
```
68
134
---
69
135
70
-
### Add a user-assigned identity
136
+
####Add a user-assigned identity
71
137
72
138
To add a user-assigned identity, you need to create a user-assigned identity resource, and then add it to your API center.
73
139
@@ -115,7 +181,7 @@ To add a user-assigned identity, you need to create a user-assigned identity res
115
181
```
116
182
---
117
183
118
-
## Assign the managed identity the API Management Service Reader role
184
+
### Assign the managed identity the API Management Service Reader role
119
185
120
186
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.
121
187
@@ -195,7 +261,7 @@ To allow import of APIs, assign your API center's managed identity the **API Man
195
261
--scope $scope
196
262
---
197
263
198
-
## Import APIs from your API Management instance
264
+
### Bulk-import APIs from your API Management instance
199
265
200
266
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.
201
267
@@ -204,7 +270,7 @@ Use the [az apic service import-from-apim](/cli/azure/apic/service#az-apic-servi
204
270
>
205
271
> * 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.
206
272
207
-
### Import all APIs from an API Management instance
273
+
#### Import all APIs from an API Management instance
208
274
209
275
Use a wildcard (`*`) to specify all APIs from the API Management instance.
210
276
@@ -229,7 +295,7 @@ Use a wildcard (`*`) to specify all APIs from the API Management instance.
229
295
> [!NOTE]
230
296
> If your API Management instance has a large number of APIs, import to your API center might take some time.
231
297
232
-
### Import a specific API from an API Management instance
298
+
#### Import a specific API from an API Management instance
233
299
234
300
Specify an API to import using its name from the API Management instance.
235
301
@@ -259,6 +325,7 @@ After importing APIs from API Management, you can view and manage the imported A
259
325
## Related content
260
326
261
327
* [Azure CLI reference for API Center](/cli/azure/apic)
328
+
* [Azure CLI reference for API Management](/cli/azure/apim)
262
329
* [Manage API inventory with Azure CLI commands](manage-apis-azure-cli.md)
263
330
* [Assign Azure roles to a managed identity](../role-based-access-control/role-assignments-portal-managed-identity.md)
264
331
* [Azure API Management documentation](../api-management/index.yml)
Copy file name to clipboardExpand all lines: articles/api-center/register-apis.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,7 +120,7 @@ To add an API definition to your version:
120
120
|**Description**| Optionally enter a description. | Description of the API definition. |
121
121
|**Specification name**| For the Demo Conference API, select **OpenAPI**. | Specification format for the API.|
122
122
|**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. |
124
124
125
125
:::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" :::
0 commit comments