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
description: Configure linting of API definitions in your API center to analyze compliance of APIs with the organization's API style guide.
5
5
ms.service: azure-api-center
6
6
ms.topic: how-to
7
-
ms.date: 02/27/2026
7
+
ms.date: 02/28/2026
8
8
9
9
ms.custom:
10
10
- devx-track-azurecli
@@ -14,16 +14,17 @@ ms.custom:
14
14
15
15
# Enable API analysis in your API center - self-managed
16
16
17
-
This article explains how to enable API analysis in [Azure API Center](overview.md) by manually setting up a linting engine and triggers. These capabilities analyze your API definitions for adherence to organizational style rules, generating both individual and summary reports. API analysis helps identify and correct common errors and inconsistencies in your API definitions.
17
+
This article explains how to enable API analysis in [Azure API Center](overview.md) to set up a linting engine and triggers. These capabilities analyze your API definitions for adherence to organizational style rules, generating both individual and summary reports. API analysis helps identify and correct common errors and inconsistencies in your API definitions.
18
+
19
+
The following procedures support **automated deployment** of the linting engine and event subscription in your API center. Use the Azure Developer CLI (`azd`) for one-step deployment of linting infrastructure for a streamlined deployment process. The Azure CLI command examples can run in PowerShell or a bash shell. Separate command examples are provided, as needed.
20
+
21
+
If you prefer to set up the engine and resources via **manual deployment**, see the [Azure API Center Analyzer](https://github.com/Azure/APICenter-Analyzer/) GitHub repository for guidance to deploy the function app and configure the event subscription.
18
22
19
23
> [!NOTE]
20
24
> Azure API Center also [automatically configures](enable-managed-api-analysis-linting.md) a default linting engine and dependencies for API analysis. If you enable self-managed analysis as described in this article, you override these built-in features.
> 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.
26
-
27
28
## Scenario overview
28
29
29
30
In this scenario, you analyze API definitions in your API center by using the [Spectral](https://github.com/stoplightio/spectral) open source linting engine. A function app built with Azure Functions runs the linting engine in response to events in your API center. Spectral checks that the APIs defined in a JSON or YAML specification document conform to the rules in a customizable API style guide. An analysis report is generated that you can view in your API center.
@@ -44,18 +45,12 @@ The following diagram shows the steps to enable linting and analysis in your API
44
45
45
46
1. View the analysis report in the API center.
46
47
47
-
### Options to deploy the linting engine and event subscription
48
-
49
-
This article provides two options to deploy the linting engine and event subscription in your API center:
50
-
51
-
-**Automated deployment**: Use the Azure Developer CLI (`azd`) for one-step deployment of linting infrastructure. This option is recommended for a streamlined deployment process.
52
-
53
-
-**Manual deployment**: Follow step-by-step guidance to deploy the function app and configure the event subscription. This option is recommended if you prefer to deploy and manage the resources manually.
54
-
55
48
### Limitations
56
49
57
50
* Linting currently supports only JSON or YAML specification files, such as OpenAPI or AsyncAPI specification documents.
51
+
58
52
* By default, the linting engine uses the built-in [`spectral:oas` ruleset](https://docs.stoplight.io/docs/spectral/4dec24461f3af-open-api-rules). To extend the ruleset or create custom API style guides, see the [Spectral repository](https://github.com/stoplightio/spectral/blob/develop/docs/reference/openapi-rules.md) on GitHub.
53
+
59
54
* The function app that invokes linting is charged separately, and you manage and maintain it.
60
55
61
56
## Prerequisites
@@ -64,20 +59,21 @@ This article provides two options to deploy the linting engine and event subscri
64
59
65
60
* The Event Grid resource provider registered in your subscription. If you need to register the Event Grid resource provider, see [Subscribe to events published by a partner with Azure Event Grid](../event-grid/subscribe-to-partner-events.md#register-the-event-grid-resource-provider).
66
61
62
+
*[Azure Developer CLI (azd)](/azure/developer/azure-developer-cli/install-azd). Install `azd` on your machine into the environment you plan to use for the following procedure.
63
+
64
+
*[Azure Functions Core Tools](/azure/azure-functions/functions-run-local). Install the core tools on your machine into the environment you plan to use for the following procedure. Make sure the tools are reachable by your `PATH` settings.
## Use azd deployment for function app and event subscription
73
72
74
-
This section provides automated steps for the Azure Developer CLI (`azd`) to configure the function app and event subscription that enable linting and analysis in your API center. You can also configure the resources [manually](#manual-steps-to-configure-function-app-and-event-subscription).
75
-
76
-
### Other prerequisites for this option
77
-
78
-
*[Azure Developer CLI (azd)](/azure/developer/azure-developer-cli/install-azd). Install `azd` on your machine into the environment you plan to use for the following procedure.
73
+
The following procedures provide automated steps for the Azure Developer CLI (`azd`) to configure the function app and event subscription that enable linting and analysis in your API center.
79
74
80
-
*[Azure Functions Core Tools](/azure/azure-functions/functions-run-local). Install the core tools on your machine into the environment you plan to use for the following procedure. Make sure the tools are reachable by your `PATH` settings.
75
+
> [!NOTE]
76
+
> If you prefer to set up the engine and resources with **manual deployment**, see the [Azure API Center Analyzer](https://github.com/Azure/APICenter-Analyzer/) GitHub repository for guidance to deploy the function app and configure the event subscription.
81
77
82
78
### Run the sample by using azd
83
79
@@ -100,11 +96,10 @@ This section provides automated steps for the Azure Developer CLI (`azd`) to con
100
96
> [!TIP]
101
97
> You can avoid authentication issues across development environments by running the following commands:
102
98
>
103
-
> 1. Create a new development environment: `azd new env`
99
+
> 1. Create a new development environment: `azd env new`
104
100
> 1. Get your tenant ID: `az account show --query tenantId -o tsv` (copy the output ID for later)
105
101
> 1. Sign out: `azd auth logout` command
106
102
> 1. Sign into `azd` with your `tenantId` value from step 2: `azd auth login --tenant-id <tenant_ID>`
107
-
> 1. Sign in again: `azd auth login`
108
103
109
104
When you successfully authenticate, the command output shows you _Logged into Azure as <your_user_alias>_.
110
105
@@ -187,7 +182,19 @@ This section provides automated steps for the Azure Developer CLI (`azd`) to con
187
182
188
183
If the `apicenter-analyer` function isn't listed or the **Status** isn't **Enabled**, [publish the function](#publish-apicenter-analyzer-function-with-azure-functions-core-tools) by using the Azure Functions Core Tools.
189
184
190
-
1.[Configure an event subscription](#configure-event-subscription-with-the-azure-cli) by using PowerShell or a bash shell in Visual Studio Code.
185
+
1.[Configure an event subscription](#configure-event-subscription) by using PowerShell or a bash shell in Visual Studio Code.
186
+
187
+
### Confirm function published in Azure portal
188
+
189
+
When the deployment completes, confirm the new function app is present in the Azure portal and the function is published.
190
+
191
+
1. Sign in to the [Azure portal](https://portal.azure.com), browse to the **Function App** section, and select your new function app in the list.
192
+
193
+
1. On the **Overview** page for the new function app, confirm the function app **Status** is **Running**.
194
+
195
+
1. In the **Functions** section, confirm the `apicenter-analyer` function is listed and the **Status** is **Enabled**.
196
+
197
+
:::image type="content" source="media/enable-api-analysis-linting/function-app-status.png" alt-text="Screenshot of the function app in the Azure portal showing the Running status and Enabled function.":::
191
198
192
199
#### Publish apicenter-analyzer function with Azure Functions Core Tools
193
200
@@ -239,187 +246,9 @@ If the deployment process doesn't publish the `apicenter-analyer` function to th
239
246
240
247
1. In the Azure portal, confirm the `apicenter-analyer` function is now [published and enabled for your function app](#confirm-function-published-in-azure-portal).
241
248
242
-
### Configure event subscription with the Azure CLI
243
-
244
-
After the function is successfully published to the function app in the Azure portal, you can [configure an event subscription](/azure/api-center/enable-api-analysis-linting?tabs=cli#configure-event-subscription-in-your-api-center) by using PowerShell or a bash shell. Then browse to your API center in the Azure portal, and confirm the new event subscription under **Events** > **Event Subscriptions**.
245
-
246
-
You can now upload an API definition file to your API center to [trigger the event subscription](#trigger-event-in-your-api-center) and run the linting engine.
247
-
248
-
249
-
## Manual steps to configure function app and event subscription
250
-
251
-
This section provides the manual deployment steps to configure the function app and event subscription to enable linting and analysis in your API center.
252
-
253
-
- Step 1: Deploy a function app to run the linting function on your API definitions.
254
-
- Step 2: Configure a system-assigned managed identity for the function app (Azure portal or the Azure CLI).
255
-
- Step 3: Create an event subscription to trigger the function app when you upload or change an API definition (Azure portal or the Azure CLI).
256
-
257
-
If you prefer automated deployment, you can use the [Azure Developer CLI (azd)](#use-azd-deployment-for-function-app-and-event-subscription).
258
-
259
-
### Other prerequisites for this option
260
-
261
-
* Visual Studio Code with the [Azure Functions extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions) version v1.10.4 or later.
262
-
263
-
### Deploy your function app
264
-
265
-
To deploy the function app that runs the linting function on API definitions:
266
-
267
-
1. Clone the [GitHub repository](https://github.com/Azure/APICenter-Analyzer/) and open it in Visual Studio Code.
268
-
269
-
1. In the `resources/rulesets` folder, locate the `oas.yaml` file. This file reflects your current API style guide and can be modified based on your organizational needs and requirements.
270
-
271
-
1. (Optional) Run the function app locally to test it. For more information, see the [README](https://github.com/Azure/APICenter-Analyzer/tree/preview#-configure--run-your-function-locally) file in the repository.
272
-
273
-
1. Deploy the function app to Azure. For instructions, see [Quickstart: Create and deploy function code to Azure by using Visual Studio Code (TypeScript)](/azure/azure-functions/how-to-create-function-vs-code?pivot=programming-language-typescript&tabs=go%2Cwindows&pivots=programming-language-typescript#sign-in-to-azure).
274
-
275
-
> [!NOTE]
276
-
> Deploying the function app can take several minutes.
277
-
278
-
### Confirm function published in Azure portal
279
-
280
-
When the deployment completes, confirm the new function app is present in the Azure portal and the function is published.
281
-
282
-
1. Sign in to the [Azure portal](https://portal.azure.com), browse to the **Function App** section, and select your new function app in the list.
283
-
284
-
1. On the **Overview** page for the new function app, confirm the function app **Status** is **Running**.
285
-
286
-
1. In the **Functions** section, confirm the `apicenter-analyer` function is listed and the **Status** is **Enabled**.
287
-
288
-
:::image type="content" source="media/enable-api-analysis-linting/function-app-status.png" alt-text="Screenshot of the function app in the Azure portal showing the Running status and Enabled function.":::
289
-
290
-
### Configure managed identity in your function app
291
-
292
-
To enable the function app to access the API center, configure a managed identity for the function app. The following steps show how to enable and configure a system-assigned managed identity for the function app by using the Azure portal or the Azure CLI.
293
-
294
-
#### [Portal](#tab/portal)
295
-
296
-
1. In the Azure portal, browse to the **Overview** page for your function app.
297
-
298
-
1. Expand **Settings** and select **Identity**.
299
-
300
-
1. On the **System assigned** tab, set the **Status** to **On** and then select **Save**.
301
-
302
-
After the managed identity is enabled, assign it the Azure API Center Compliance Manager role to access the API center.
303
-
304
-
1. In the [Azure portal](https://portal.azure.com), browse to your API center, and select **Access control (IAM)**.
249
+
### Configure event subscription
305
250
306
-
1. Select **+ Add > Add role assignment**.
307
-
308
-
1. On the **Job function roles** tab, select **Azure API Center Compliance Manager** in the list, and select **Next**.
309
-
310
-
1. On the **Members** page, in the **Assign access to** box, select **Managed identity**, and then choose **+ Select members**.
311
-
312
-
1. On the **Select managed identities** page, search for and select the managed identity of the function app. Choose **Select**.
313
-
314
-
1. On the **Add role assignment** page, select **Next**.
315
-
316
-
1. Review the role assignment, and select **Review + assign**.
317
-
318
-
#### [Azure CLI](#tab/cli)
319
-
320
-
1. Enable the system-assigned identity of the function app by using the [az functionapp identity assign](/cli/azure/functionapp/identity#az-functionapp-identity-assign) command. The following command stores the principal ID of the system-assigned managed identity in the `principalID` variable.
321
-
322
-
Replace `<function-app-name>` and `<resource-group-name>` with your function app name and the name of the resource group for your function app.
Replace `<apic-name>` and `<resource-group-name>` with your API center name and the name of the resource group for your API center.
341
-
342
-
```azurecli
343
-
#! /bin/bash
344
-
apicID=$(az apic show --name <apic-name> --resource-group <resource-group-name> \
345
-
--query "id" --output tsv)
346
-
```
347
-
348
-
```azurecli
349
-
# PowerShell syntax
350
-
$apicID=$(az apic show --name <apic-name> --resource-group <resource-group-name> `
351
-
--query "id" --output tsv)
352
-
```
353
-
354
-
1. Assign the function app's managed identity the Azure API Center Compliance Manager role in the API center using the [az role assignment create](/cli/azure/role/assignment#az-role-assignment-create) command.
355
-
356
-
```azurecli
357
-
#! /bin/bash
358
-
az role assignment create \
359
-
--role "Azure API Center Compliance Manager" \
360
-
--assignee-object-id $principalID \
361
-
--assignee-principal-type ServicePrincipal \
362
-
--scope $apicID
363
-
```
364
-
365
-
```azurecli
366
-
# PowerShell syntax
367
-
az role assignment create `
368
-
--role "Azure API Center Compliance Manager" `
369
-
--assignee-object-id $principalID `
370
-
--assignee-principal-type ServicePrincipal `
371
-
--scope $apicID
372
-
```
373
-
---
374
-
375
-
### Configure event subscription in your API center
376
-
377
-
Now create an event subscription in your API center to trigger the function app when an API definition file is uploaded or updated. The following steps show how to create the event subscription by using the Azure portal or the Azure CLI.
378
-
379
-
#### [Portal](#tab/portal)
380
-
381
-
1. In the [Azure portal](https://portal.azure.com), browse to your API center, and select **Events**.
382
-
383
-
1. Select **+ Event Subscription**.
384
-
385
-
1. On the **Create Event Subscription** page, complete the following configuration:
386
-
387
-
1. Enter a descriptive **Name** for the event subscription.
388
-
389
-
1. For the **Event Schema**, select **Event Grid Schema**.
390
-
391
-
1. Expand the **Event Types** dropdown list, and select the checkboxes for the following events:
392
-
393
-
- **API definition added**
394
-
- **API definition updated**
395
-
396
-
1. Expand the **Endpoint Details** dropdown list, and select **Azure Function**.
397
-
398
-
1. To provide an **Endpoint** value, select **Configure an endpoint**.
399
-
400
-
In the **Select Azure Function** page, configure the following settings:
401
-
402
-
1. Select the **Subscription** for your API center, and **Resource group** for your new function app.
403
-
404
-
1. As needed, provide a **System Topic Name** under **Topic details**.
405
-
406
-
1. Set the **Function app** to your new function app.
407
-
408
-
The **Slot** and **Function** values are configured for you based on your other selections.
409
-
410
-
Select **Confirm Selection**.
411
-
412
-
1. Select **Create**.
413
-
414
-
:::image type="content" source="media/enable-api-analysis-linting/create-event-subscription.png" alt-text="Screenshot of creating the event subscription in the Azure portal.":::
415
-
416
-
1. Select the **Event Subscriptions** tab, and select **Refresh**.
417
-
418
-
1. At the bottom of the page, locate the new event subscription in the list and confirm the **Provisioning state** is **Succeeded**.
419
-
420
-
:::image type="content" source="media/enable-api-analysis-linting/event-subscription-provisioning-state.png" alt-text="Screenshot of the state of the event subscription in the Azure portal." lightbox="media/enable-api-analysis-linting/event-subscription-provisioning-state.png":::
421
-
422
-
#### [Azure CLI](#tab/cli)
251
+
After the function is successfully published to the function app in the Azure portal, you can create an event subscription in your API center to trigger the function app when an API definition file is uploaded or updated.
423
252
424
253
1. Get the resource ID of your API center. Substitute `<apic-name>` and `<resource-group-name>` with your API center name and the name of the resource group for your API center.
425
254
@@ -474,10 +303,11 @@ Now create an event subscription in your API center to trigger the function app
474
303
```azurecli
475
304
az eventgrid event-subscription show --name MyEventSubscription --source-resource-id "$apicID"
476
305
```
477
-
---
478
306
479
-
> [!NOTE]
480
-
> It can take a short time for the event subscription to propagate to the function app.
307
+
> [!NOTE]
308
+
> It can take a short time for the event subscription to propagate to the function app.
309
+
310
+
1. Browse to your API center in the Azure portal, and confirm the new event subscription under **Events** > **Event Subscriptions**.
0 commit comments