Skip to content

Commit 9edae37

Browse files
authored
Document the "az grafana api-key create" command
It is much easier to use the az grafana api-key create command to obtain a Bearer token. I document this option in the pull request. Originally posted at #107629
1 parent 3ee69db commit 9edae37

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

articles/managed-grafana/how-to-api-calls.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,31 @@ You now need to gather some information, which you'll use to get a Grafana API a
8383

8484
## Get an access token
8585

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 Command-Line Interface (CLI) or making a POST request.
87+
88+
### Get an access token using the Azure Command-Line Interface (CLI)
89+
90+
Replace `<tenant-id>`, `<client-id>`, and `<client-secret>` with the tenant ID, application (client) ID, and client secret collected in the previous step and login with Azure CLI:
91+
92+
```
93+
az login --service-principal -u "<client-id>" -p "client-secret>" --tenant "<tenant-id>"
94+
```
95+
96+
Use the command `az grafana api-key create` to create a key, here is an example output:
97+
98+
```
99+
az grafana api-key create --key keyname --name <name> -g <rg> -r editor -o json
100+
You will only be able to view this key here once. Please save it in a secure place.
101+
{
102+
"id": 3,
103+
"key": "<redacted>",
104+
"name": "keyname"
105+
}
106+
```
107+
108+
### Get an access token using a POST request
109+
110+
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.
87111

88112
```bash
89113
curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' \

0 commit comments

Comments
 (0)