Skip to content

Commit ceee11a

Browse files
authored
Merge pull request #279653 from dlepow/cliext
[APIC] CLI updates
2 parents dffeb47 + 29512c2 commit ceee11a

File tree

5 files changed

+68
-72
lines changed

5 files changed

+68
-72
lines changed

articles/api-center/enable-api-analysis-linting.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Perform API linting and analysis - Azure API Center
33
description: Configure linting of API definitions in your API center to analyze compliance of APIs with the organization's API style guide.
44
ms.service: api-center
55
ms.topic: how-to
6-
ms.date: 04/22/2024
6+
ms.date: 06/29/2024
77
ms.author: danlep
88
author: dlepow
99
ms.custom: devx-track-azurecli
@@ -169,13 +169,13 @@ Now that the managed identity is enabled, assign it the Azure API Center Complia
169169
170170
```azurecli
171171
#! /bin/bash
172-
apicID=$(az apic service show --name <apic-name> --resource-group <resource-group-name> \
172+
apicID=$(az apic show --name <apic-name> --resource-group <resource-group-name> \
173173
--query "id" --output tsv)
174174
```
175175
176176
```azurecli
177177
# PowerShell syntax
178-
$apicID=$(az apic service show --name <apic-name> --resource-group <resource-group-name> `
178+
$apicID=$(az apic show --name <apic-name> --resource-group <resource-group-name> `
179179
--query "id" --output tsv)
180180
```
181181
@@ -231,13 +231,13 @@ Now create an event subscription in your API center to trigger the function app
231231
232232
```azurecli
233233
#! /bin/bash
234-
apicID=$(az apic service show --name <apic-name> --resource-group <resource-group-name> \
234+
apicID=$(az apic show --name <apic-name> --resource-group <resource-group-name> \
235235
--query "id" --output tsv)
236236
```
237237
238238
```azurecli
239239
# PowerShell syntax
240-
$apicID=$(az apic service show --name <apic-name> --resource-group <resource-group-name> `
240+
$apicID=$(az apic show --name <apic-name> --resource-group <resource-group-name> `
241241
--query "id" --output tsv)
242242
```
243243
1. Get the resource ID of the function in the function app. In this example, the function name is *apicenter-analyzer*. Substitute `<function-app-name>` and `<resource-group-name>` with your function app name and resource group name.

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

Lines changed: 45 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Add APIs to your Azure API center inventory from your API Managemen
44
author: dlepow
55
ms.service: api-center
66
ms.topic: how-to
7-
ms.date: 04/30/2024
7+
ms.date: 06/28/2024
88
ms.author: danlep
99
ms.custom: devx-track-azurecli
1010
# Customer intent: As an API program manager, I want to add APIs that are managed in my Azure API Management instance to my API center.
@@ -22,12 +22,10 @@ This article shows two options for using the Azure CLI to add APIs to your API c
2222
* Run [az apic api register](/cli/azure/apic/api#az-apic-api-register) to register a new API in your API center.
2323
* Run [az apic api definition import-specification](/cli/azure/apic/api/definition#az-apic-api-definition-import-specification) to import the API definition to an existing API.
2424

25-
* **Option 2** - Import APIs directly 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.
25+
* **Option 2** - Import APIs directly from API Management to your API center using the [az apic import-from-apim](/cli/azure/apic/az-apic-import-from-apim) command.
2626

2727
After importing API definitions or APIs from API Management, you can add metadata and documentation in your API center to help stakeholders discover, understand, and consume the API.
2828

29-
> [!VIDEO https://www.youtube.com/embed/SuGkhuBUV5k]
30-
3129
## Prerequisites
3230

3331
* An API center in your Azure subscription. If you haven't created one, see [Quickstart: Create your API center](set-up-api-center.md).
@@ -50,7 +48,7 @@ First, export an API from your API Management instance to an API definition usin
5048

5149
### Export API to a local API definition file
5250

53-
The following example command 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*.
51+
The following example command 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 at the path you specify.
5452

5553
```azurecli
5654
#! /bin/bash
@@ -90,7 +88,7 @@ You can register a new API in your API center from the exported definition by us
9088
The following example registers an API in the *myAPICenter* API center from a local OpenAPI definition file named *definitionFile.json*.
9189

9290
```azurecli
93-
az apic api register --resource-group myResourceGroup --service myAPICenter --api-location "/path/to/definitionFile.json"
91+
az apic api register --resource-group myResourceGroup --service-name myAPICenter --api-location "/path/to/definitionFile.json"
9492
```
9593

9694
### Import API definition to an existing API in your API center
@@ -102,7 +100,7 @@ This example assumes you have an API named *my-api* and an associated API versio
102100
```azurecli
103101
#! /bin/bash
104102
az apic api definition import-specification \
105-
--resource-group myResourceGroup --service myAPICenter \
103+
--resource-group myResourceGroup --service-name myAPICenter \
106104
--api-id my-api --version-id v1-0-0 \
107105
--definition-id openapi --format "link" --value '$link' \
108106
--specification '{"name":"openapi","version":"3.0.2"}'
@@ -111,17 +109,17 @@ az apic api definition import-specification \
111109
```azurecli
112110
# PowerShell syntax
113111
az apic api definition import-specification `
114-
--resource-group myResourceGroup --service myAPICenter `
112+
--resource-group myResourceGroup --service-name myAPICenter `
115113
--api-id my-api --version-id v1-0-0 `
116114
--definition-id openapi --format "link" --value '$link' `
117115
--specification '{"name":"openapi","version":"3.0.2"}'
118116
```
119117

120118
## Option 2: Import APIs directly from your API Management instance
121119

122-
The following are steps to import APIs from your API Management instance to your API center using the [az apic service import-from-apim](/cli/azure/apic/service#az-apic-service-import-from-apim) command. This command is useful when you want to import multiple APIs from API Management to your API center, but you can also use it to import a single API.
120+
The following are steps to import APIs from your API Management instance to your API center using the [az apic import-from-apim](/cli/azure/apic#az-apic-service-import-from-apim) command. This command is useful when you want to import multiple APIs from API Management to your API center, but you can also use it to import a single API.
123121

124-
When you add APIs from an API Management instance to your API center using `az apic service import-from-apim`, the following happens automatically:
122+
When you add APIs from an API Management instance to your API center using `az apic import-from-apim`, the following happens automatically:
125123

126124
* Each 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.
127125
* The API receives a system-generated API name in your API center. It retains its display name (title) from API Management.
@@ -143,10 +141,10 @@ The following examples show how to configure a system-assigned managed identity
143141

144142
#### [Azure CLI](#tab/cli)
145143

146-
Set the system-assigned identity in your API center using the following [az apic service update](/cli/azure/apic/service#az-apic-service-update) command. Substitute the names of your API center and resource group:
144+
Set the system-assigned identity in your API center using the following [az apic update](/cli/azure/apic#az-apic-update) command. Substitute the names of your API center and resource group:
147145

148146
```azurecli
149-
az apic service update --name <api-center-name> --resource-group <resource-group-name> --identity '{"type": "SystemAssigned"}'
147+
az apic update --name <api-center-name> --resource-group <resource-group-name> --identity '{"type": "SystemAssigned"}'
150148
```
151149
---
152150

@@ -167,18 +165,18 @@ To allow import of APIs, assign your API center's managed identity the **API Man
167165

168166
#### [Azure CLI](#tab/cli)
169167

170-
1. Get the principal ID of the identity. For a system-assigned identity, use the [az apic service show](/cli/azure/apic/service#az-apic-service-show) command.
168+
1. Get the principal ID of the identity. For a system-assigned identity, use the [az apic show](/cli/azure/apic#az-apic-show) command.
171169

172170
```azurecli
173171
#! /bin/bash
174-
apicObjID=$(az apic service show --name <api-center-name> \
172+
apicObjID=$(az apic show --name <api-center-name> \
175173
--resource-group <resource-group-name> \
176174
--query "identity.principalId" --output tsv)
177175
```
178176
179177
```azurecli
180178
# PowerShell syntax
181-
$apicObjID=$(az apic service show --name <api-center-name> `
179+
$apicObjID=$(az apic show --name <api-center-name> `
182180
--resource-group <resource-group-name> `
183181
--query "identity.principalId" --output tsv)
184182
```
@@ -221,7 +219,7 @@ To allow import of APIs, assign your API center's managed identity the **API Man
221219
222220
### Import APIs from API Management
223221
224-
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.
222+
Use the [az apic import-from-apim](/cli/azure/apic#az-apic-import-from-apim) command to import one or more APIs from your API Management instance to your API center.
225223
226224
> [!NOTE]
227225
> * This command depends on a managed identity configured in your API center that has read permissions to the API Management instance. If you haven't added or configured a managed identity, see [Add a managed identity in your API center](#add-a-managed-identity-in-your-api-center) earlier in this article.
@@ -230,53 +228,48 @@ Use the [az apic service import-from-apim](/cli/azure/apic/service#az-apic-servi
230228
231229
#### Import all APIs from an API Management instance
232230
233-
Use a wildcard (`*`) to specify all APIs from the API Management instance.
234-
235-
1. Get the resource ID of your API Management instance using the [az apim show](/cli/azure/apim#az-apim-show) command.
231+
In the following command, substitute the names of your API center, your API center's resource group, your API Management instance, and your instance's resource group. Use `*` to specify all APIs from the API Management instance.
236232
237-
```azurecli
238-
#! /bin/bash
239-
apimID=$(az apim show --name <apim-name> --resource-group <resource-group-name> --query id --output tsv)
240-
```
241-
242-
```azurecli
243-
# PowerShell syntax
244-
$apimID=$(az apim show --name <apim-name> --resource-group <resource-group-name> --query id --output tsv)
245-
```
246-
247-
1. Use the `az apic service import-from-apim` command to import the APIs. Substitute the names of your API center and resource group, and use `*` to specify all APIs from the API Management instance.
233+
```azurecli
234+
#! /bin/bash
235+
az apic import-from-apim --service-name <api-center-name> --resource-group <resource-group-name> \
236+
--apim-name <api-management-name> --apim-resource-group <api-management-resource-group-name> \
237+
--apim-apis '*'
238+
```
248239

249-
```azurecli
250-
az apic service import-from-apim --service-name <api-center-name> --resource-group <resource-group-name> --source-resource-ids $apimID/apis/*
251-
```
240+
```azurecli
241+
# PowerShell syntax
242+
az apic import-from-apim --service-name <api-center-name> --resource-group <resource-group-name> `
243+
--apim-name <api-management-name> --apim-resource-group <api-management-resource-group-name> `
244+
--apim-apis '*'
245+
```
252246

253-
> [!NOTE]
254-
> If your API Management instance has a large number of APIs, import to your API center might take some time.
247+
> [!NOTE]
248+
> If your API Management instance has a large number of APIs, import to your API center might take some time.
255249
256250
#### Import a specific API from an API Management instance
257251

258252
Specify an API to import using its name from the API Management instance.
259253

260-
1. Get the resource ID of your API Management instance using the [az apim show](/cli/azure/apim#az-apim-show) command.
254+
In the following command, substitute the names of your API center, your API center's resource group, your API Management instance, and your instance's resource group. Pass an API name such as `petstore-api` using the `--apim-apis` parameter.
261255

262-
```azurecli
263-
#! /bin/bash
264-
apimID=$(az apim show --name <apim-name> --resource-group <resource-group-name> --query id --output tsv)
265-
```
256+
```azurecli
257+
#! /bin/bash
258+
import-from-apim --service-name <api-center-name> --resource-group <resource-group-name> \
259+
--apim-name <api-management-name> --apim-resource-group <api-management-resource-group-name> \
260+
--apim-apis 'petstore-api'
261+
```
266262

267-
```azurecli
268-
# PowerShell syntax
269-
$apimID=$(az apim show --name <apim-name> --resource-group <resource-group-name> --query id --output tsv)
270-
```
271-
272-
1. Use the `az apic service import-from-apim` command to import the API. Substitute the names of your API center and resource group, and specify an API name from the API Management instance.
273263

274-
```azurecli
275-
az apic service import-from-apim --service-name <api-center-name> --resource-group <resource-group-name> --source-resource-ids $apimID/apis/<api-name>
276-
```
277-
278-
> [!NOTE]
279-
> Specify `<api-name>` using the API resource name in the API Management instance, not the display name. Example: `petstore-api` instead of `Petstore API`.
264+
```azurecli
265+
# PowerShell syntax
266+
import-from-apim --service-name <api-center-name> --resource-group <resource-group-name> `
267+
--apim-name <api-management-name> --apim-resource-group <api-management-resource-group-name> `
268+
--apim-apis 'petstore-api'
269+
```
270+
271+
> [!NOTE]
272+
> Specify an API name using the API resource name in the API Management instance, not the display name. Example: `petstore-api` instead of `Petstore API`.
280273
281274
After importing APIs from API Management, you can view and manage the imported APIs in your API center.
282275

articles/api-center/includes/install-apic-extension.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ ms.custom: Include file
1313

1414
> [!NOTE]
1515
> `az apic` commands require the `apic-extension` Azure CLI extension. If you haven't used `az apic` commands, the extension can be installed dynamically when you run your first `az apic` command, or you can install the extension manually. Learn more about [Azure CLI extensions](/cli/azure/azure-cli-extensions-overview).
16+
>
17+
> See the [release notes](https://github.com/Azure/azure-cli-extensions/blob/main/src/apic-extension/HISTORY.rst) for the latest changes and updates in the `apic-extension`.

articles/api-center/manage-apis-azure-cli.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: dlepow
55
ms.service: api-center
66
ms.custom: devx-track-azurecli
77
ms.topic: how-to
8-
ms.date: 04/30/2024
8+
ms. date: 06/28/2024
99
ms.author: danlep
1010
# Customer intent: As an API program manager, I want to automate processes to register and update APIs in my Azure API center.
1111
---
@@ -14,8 +14,6 @@ ms.author: danlep
1414

1515
This article shows how to use [`az apic api`](/cli/azure/apic/api) commands in the Azure CLI to add and configure APIs in your [API center](overview.md) inventory. Use commands in the Azure CLI to script operations to manage your API inventory and other aspects of your API center.
1616

17-
> [!VIDEO https://www.youtube.com/embed/Dvar8Dg25s0]
18-
1917
## Prerequisites
2018

2119
* An API center in your Azure subscription. If you haven't created one already, see [Quickstart: Create your API center](set-up-api-center.md).
@@ -37,7 +35,7 @@ The following example creates an API named *Petstore API* in the *myResourceGrou
3735

3836
```azurecli-interactive
3937
az apic api create --resource-group myResourceGroup \
40-
--service myAPICenter --api-id petstore-api \
38+
--service-name myAPICenter --api-id petstore-api \
4139
--title "Petstore API" --type "rest"
4240
```
4341

@@ -53,7 +51,7 @@ The following example creates an API version named *v1-0-0* for the *petstore-ap
5351

5452
```azurecli-interactive
5553
az apic api version create --resource-group myResourceGroup \
56-
--service myAPICenter --api-id petstore-api \
54+
--service-name myAPICenter --api-id petstore-api \
5755
--version-id v1-0-0 --title "v1-0-0" --lifecycle-stage "testing"
5856
```
5957

@@ -67,7 +65,7 @@ The following example uses the [az apic api definition create](/cli/azure/apic/a
6765

6866
```azurecli-interactive
6967
az apic api definition create --resource-group myResourceGroup \
70-
--service myAPICenter --api-id petstore-api \
68+
--service-name myAPICenter --api-id petstore-api \
7169
--version-id v1-0-0 --definition-id openapi --title "OpenAPI"
7270
```
7371

@@ -80,7 +78,7 @@ The following example imports an OpenAPI specification file from a publicly acce
8078

8179
```azurecli-interactive
8280
az apic api definition import-specification \
83-
--resource-group myResourceGroup --service myAPICenter \
81+
--resource-group myResourceGroup --service-name myAPICenter \
8482
--api-id petstore-api --version-id v1-0-0 \
8583
--definition-id openapi --format "link" \
8684
--value 'https://petstore3.swagger.io/api/v3/openapi.json' \
@@ -98,7 +96,7 @@ The following example exports the specification file from the *openapi* definiti
9896

9997
```azurecli-interactive
10098
az apic api definition export-specification \
101-
--resource-group myResourceGroup --service myAPICenter \
99+
--resource-group myResourceGroup --service-name myAPICenter \
102100
--api-id petstore-api --version-id v1-0-0 \
103101
--definition-id openapi --file-name "/Path/to/specificationFile.json"
104102
```
@@ -112,7 +110,7 @@ The following example registers an API in the *myAPICenter* API center from a lo
112110

113111
```azurecli-interactive
114112
az apic api register --resource-group myResourceGroup \
115-
--service myAPICenter --api-location "/Path/to/specificationFile.json"
113+
--service-name myAPICenter --api-location "/Path/to/specificationFile.json"
116114
```
117115

118116
* The command sets the API properties such as name and type from values in the definition file.
@@ -127,7 +125,7 @@ Use the [az apic api delete](/cli/azure/apic/api#az_apic_api_delete) command to
127125

128126
```azurecli-interactive
129127
az apic api delete \
130-
--resource-group myResoureGroup --service myAPICenter \
128+
--resource-group myResoureGroup --service-name myAPICenter \
131129
--api-id petstore-api
132130
```
133131

articles/api-center/set-up-api-center-azure-cli.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: dlepow
55
ms.service: api-center
66
ms.custom: devx-track-azurecli
77
ms.topic: quickstart
8-
ms.date: 04/19/2024
8+
ms.daate: 06/27/2024
99
ms.author: danlep
1010
---
1111

@@ -48,12 +48,12 @@ az group create --name MyGroup --location eastus
4848

4949
## Create an API center
5050

51-
Create an API center using the [`az apic service create`](/cli/azure/apic/service#az-apic-service-create) command.
51+
Create an API center using the [`az apic create`](/cli/azure/apic/#az-apic-create) command.
5252

5353
The following example creates an API center called *MyApiCenter* in the *MyGroup* resource group. In this example, the API center is deployed in the *West Europe* location. Substitute an API center name of your choice and enter one of the [available locations](overview.md#available-regions) for your API center.
5454

5555
```azurecli-interactive
56-
az apic service create --name MyApiCenter --resource-group MyGroup --location westeurope
56+
az apic create --name MyApiCenter --resource-group MyGroup --location westeurope
5757
```
5858

5959
Output from the command looks similar to the following. By default, the API center is created in the Free plan.
@@ -65,9 +65,12 @@ Output from the command looks similar to the following. By default, the API cent
6565
"location": "westeurope",
6666
"name": "myapicenter",
6767
"resourceGroup": "mygroup",
68+
"sku": {
69+
"name": "Free"
70+
},
6871
"systemData": {
69-
"createdAt": "2024-04-22T21:40:35.2541624Z",
70-
"lastModifiedAt": "2024-04-22T21:40:35.2541624Z"
72+
"createdAt": "2024-06-22T21:40:35.2541624Z",
73+
"lastModifiedAt": "2024-06-22T21:40:35.2541624Z"
7174
},
7275
"tags": {},
7376
"type": "Microsoft.ApiCenter/services"

0 commit comments

Comments
 (0)