Comment faire une authentification pour API Rest subcription Azure Openaiest subcription Azure Openai le scope =/subscriptions/00000000-0000-0000-0000-00000000/resourceGroup
Bonjour nous souhaitons récupérer des informations sur notre souscription sur AzureOpenAI via API Rest afin de l'intégrer dans un power bi nous avons trouvé l'URL pour récupérer les informations :
curl --location 'https://management.azure.com/subscriptions/a6e3c2d8-3c49-4f44-9915-0cf9b61dcdc5/resourceGroups/davidson-data/providers/Microsoft.CostManagement/query?api-version=2024-08-01&expor=null' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {Bearer_token}' \
--data '{
"type": "Usage",
"timeframe": "Custom",
"timePeriod": {
"from": "2024-10-01T00:00:00Z",
"to": "2024-11-30T00:00:00Z"
},
"dataset": {
"granularity": "Daily",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceGroup"
}
]
}
}
Le problème c'est la partie Authentification qui bloque {bearer_token}
On a trouvé cette requête POST :
curl --location 'https://login.microsoftonline.com/a6e3c2d8-3c49-4f44-9915-0cf9b61dcdc5/oauth2/v2.0/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic bmljb2xhcy5yb3NzYXJkLnR3QGRhdmlkc29uLmZyOg==' \
--header 'Cookie: fpc=AogELIAG0udCicy361Vn4Ht8MIKnAQAAAH4mNd8OAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=https://management.azure.com/.default'
Mais il nous manque des informations comme
client_id
client_secret
grant_type
La documentation ici n'est pas très claire sur le sujet
Pour résumer :
Avoir une requête permettant de récupérer le coût de notre souscription entre deux dates sur Azure
Merci beaucoup