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/managed-grafana/how-to-api-calls.md
+31-2Lines changed: 31 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ author: maud-lv
6
6
ms.author: malev
7
7
ms.service: managed-grafana
8
8
ms.topic: tutorial
9
-
ms.date: 03/23/2023
9
+
ms.date: 04/05/2023
10
10
ms.custom: engagement-fy23
11
11
---
12
12
@@ -83,7 +83,34 @@ You now need to gather some information, which you'll use to get a Grafana API a
83
83
84
84
## Get an access token
85
85
86
-
To access Grafana APIs, you need to get an access token. Follow the example below to call Azure AD and retrieve a token. Replace `<tenant-id>`, `<client-id>`, and `<client-secret>` with the tenant ID, application (client) ID, and client secret collected in the previous step.
86
+
To access Grafana APIs, you need to get an access token. You can get the access token using the Azure CLI or making a POST request.
87
+
88
+
### [Azure CLI](#tab/azure-cli)
89
+
90
+
Sign in to the Azure CLI by running the [az login](/cli/azure/reference-index#az-login) command and replace `<client-id>`, `<client-secret>`, and `<tenant-id>` with the application (client) ID, client secret, and tenant ID collected in the previous step:
91
+
92
+
```
93
+
az login --service-principal --username "<client-id>" --password "<client-secret>" --tenant "<tenant-id>"
94
+
```
95
+
96
+
Use the command [az grafana api-key create](/cli/azure/grafana/api-key#az-grafana-api-key-create) to create a key. Here's an example output:
> You can only view this key here once. Save it in a secure place.
110
+
111
+
### [POST request](#tab/post)
112
+
113
+
Follow the example below to call Azure AD and retrieve a token. Replace `<tenant-id>`, `<client-id>`, and `<client-secret>` with the tenant ID, application (client) ID, and client secret collected in the previous step.
87
114
88
115
```bash
89
116
curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' \
@@ -105,6 +132,8 @@ Here's an example of response:
105
132
}
106
133
```
107
134
135
+
---
136
+
108
137
## Call Grafana APIs
109
138
110
139
You can now call Grafana APIs using the access token retrieved in the previous step as the Authorization header. For example:
0 commit comments