Skip to content

Commit 60c833c

Browse files
committed
polish
1 parent 1d5c3b4 commit 60c833c

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

articles/api-center/register-apis-github-actions.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ Using a GitHub Actions workflow to register APIs in your API center provides a c
1818

1919
The following diagram shows how API registration in your API center can be automated using a GitHub Actions workflow.
2020

21-
:::image type="content" source="media/register-apis-github-actions/scenario-overview.svg" alt-text="Diagram showing steps to trigger a GitHub actions workflow to register an API in an Azure API center.":::
22-
21+
:::image type="content" source="media/register-apis-github-actions/scenario-overview.svg" alt-text="Diagram showing steps to trigger a GitHub actions workflow to register an API in an Azure API center." lightbox="media/register-apis-github-actions/scenario-overview.svg":::
2322

2423
1. Set up a GitHub Actions workflow in your repository that triggers when a pull request that adds an API definition file is merged.
2524
1. Create a branch from the main branch in your GitHub repository.
@@ -54,9 +53,11 @@ In this section, you set up the GitHub Actions workflow for this scenario:
5453
In the following steps, create a Microsoft Entra ID service principal, which will be used in the workflow to authenticate with Azure.
5554

5655
> [!NOTE]
57-
> Configuring a service principal is shown for demonstration purposes. The recommended way to authenticate with Azure for GitHub Actions is with OpenID Connect, an authentication method that uses short-lived tokens. Setting up OpenID Connect with GitHub Actions is more complex but offers hardened security. [Learn more](../app-service/deploy-github-actions?tabs=openid%2Caspnetcore#1-generate-deployment-credentials)
56+
> Configuring a service principal is shown for demonstration purposes. The recommended way to authenticate with Azure for GitHub Actions is with OpenID Connect, an authentication method that uses short-lived tokens. Setting up OpenID Connect with GitHub Actions is more complex but offers hardened security. [Learn more](../app-service/deploy-github-actions.md?tabs=openid%2Caspnetcore#1-generate-deployment-credentials)
57+
58+
Create a service principal using the [az ad sp create-for-rbac](/cli/azure/ad#az-ad-sp-create-for-rbac) command. The following example first uses the [az apic show](/cli/azure/apic#az-apic-show) command to retrieve the resource ID of the API center. The service principal is then created with the Contributor role for the API center.
5859

59-
Create a service principal using the [az ad sp create-for-rbac](/cli/azure/ad#az-ad-sp-create-for-rbac) command. The following example first uses the [az apic show](/cli/azure/az/apic#az-apic-show) command to retrieve the resource ID of the API center. The service principal is then created with the Contributor role for the API center.
60+
#### [Bash](#tab/bash)
6061

6162
```azurecli
6263
#! /bin/bash
@@ -69,6 +70,8 @@ apicResourceId=$(az apic show --name $apiCenter --resource-group $resourceGroup
6970
az ad sp create-for-rbac --name $spName --role Contributor --scopes $apicResourceId --json-auth
7071
```
7172

73+
#### [PowerShell](#tab/powershell)
74+
7275
```azurecli
7376
# PowerShell syntax
7477
$apiCenter = "<api-center-name>"
@@ -79,7 +82,7 @@ $apicResourceId = $(az apic show --name $apiCenter --resource-group $resourceGro
7982
8083
az ad sp create-for-rbac --name $spName --role Contributor --scopes $apicResourceId --json-auth
8184
```
82-
85+
---
8386

8487
Copy the JSON output, which should look similar to the following:
8588

@@ -117,16 +120,16 @@ The following is a basic workflow file for this example that you can use or modi
117120
118121
In this example:
119122
* the workflow is triggered when a pull request that adds a JSON definition in the `APIs` path is closed on the main branch
120-
* The location of the definition is extracted from the pull request using a GitHub script, authenticated with the default GitHub token
123+
* The location of the definition is extracted from the pull request using a GitHub script, which is authenticated with the default GitHub token
121124
* The Azure credentials saved in your repo are used to sign into Azure
122125
* The [az apic register](/cli/azure/apic/api#az-apic-api-register) command registers the API in the API center specified in the environment variables
123126

124127
To configure the workflow file:
125128

126129
1. Copy and save the file under a name such as `register-api.yml`.
127130
1. Update the values for the environment variables to match your API center in Azure.
128-
1. Update the expected path where you'll add the definition file in the repository.
129-
1. Add this file in the `/.github/workflows/` path in your GitHub repository.
131+
1. Confirm or update the name of the repository folder (`APIs`) where you'll add the API definition file.
132+
1. Add this workflow file in the `/.github/workflows/` path in your GitHub repository.
130133

131134
> [!TIP]
132135
> If you use the [Visual Studio Code extension](use-vscode-extension.md) for Azure API Center, you can generate a starting workflow file using an extension command. In the Command Palette, select **Azure API Center: Register APIs**. Select **CI/CD** > **GitHub**. You can then modify the file for your scenario.
@@ -219,7 +222,7 @@ Verify that the API is registered in your API center.
219222
To add a new version to an existing API in your API center, follow the same steps as before, with a slight modification:
220223

221224
1. Change to the same working branch in your repo, or create a new working branch.
222-
1. Add a new API definition file to the repository in the `APIs` path, in the folder for an existing API. for example, if you previously added a catfacts-api API definition, add a new version such as `APIs/catfacts-api/07-22-2024.json`.
225+
1. Add a new API definition file to the repository in the `APIs` path, in the folder for an existing API. for example, if you previously added a Cat Facts API definition, add a new version such as `APIs/catfacts-api/07-22-2024.json`.
223226
1. Commit the changes and push them to the working branch.
224227
1. Create a pull request to merge the working branch into the main branch.
225228
1. After review, merge the pull request. The merge triggers the GitHub Actions workflow that registers the new API version in your API center.
@@ -244,8 +247,8 @@ You can extend the GitHub Actions workflow to include other steps, such as addin
244247
* Apply the metadata to the API registration using the [az apic api update](/cli/azure/apic/api#az-apic-api-update) command. In the following example, the API ID and metadata file are passed in environment variables:
245248

246249

247-
```azurecli
248-
az apic api update -g ${{ env.RESOURCE_GROUP }} -n ${{ env.SERVICE_NAME }} --api-id {{ env.API_ID }} --metadata-file {{ env.METADATA_FILE }}
250+
```azurecli
251+
az apic api update -g ${{ env.RESOURCE_GROUP }} -n ${{ env.SERVICE_NAME }} --api-id {{ env.API_ID }} --metadata-file {{ env.METADATA_FILE }}
249252
```
250253

251254

0 commit comments

Comments
 (0)