Hello
I’m trying to connect centreon to Azure do begin monitoring various elements, but I’m starting with Azure recovery
I tried to follow Superviser Microsoft Azure avec Centreon but whatever I do, I get an error whatever Azure plugin I try (I only tried cloud::azure::management::recovery::plugin and .cloud::azure::compute::virtualmachine::plugin)
I’ll focus on cloud::azure::management::recovery::plugin, this uses the Azure Service Management API, I created the Active directory APP, created a secret like the article was saying
but nowhere in the article or the doc could I find the “API Rights” to grant to App. I of course tried to add the corresponding api right to the App, and granted the admin consent, also added a few other rights as I’ll use this to also monitor some o365 service and that part was documented somewhere
I’ve tried other right also, nothing worked whatever I do I get the same error
I tried with the plugin pack or with the latest git pull from the repo:
./centreon_plugins.pl --plugin=cloud::azure::management::recovery::plugin --mode=backup-items-status --custommode='api' --vault-name='vault-abc' --resource-group='ABC' --subscription='f---1' --tenant='xxx' --client-id='yyy' --client-secret='zzz'
UNKNOWN: Management endpoint API returns error code 'AuthorizationFailed'
debug output:
Host: management.azure.com
Accept:application/json
Authorization:Bearer snip=> Recv header: HTTP/1.1 403 Forbidden
=> Recv header: Cache-Control: no-cache
=> Recv header: Pragma: no-cache
=> Recv header: Content-Type: application/json; charset=utf-8
=> Recv header: Expires: -1
=> Recv header: x-ms-failure-cause: gateway
=> Recv header: x-ms-request-id: 0--b3f1
=> Recv header: x-ms-correlation-request-id: 0--f1
=> Recv header: x-ms-routing-request-id: FRANCECENTRAL:20220608T165516Z:0--b3f1
=> Recv header: Strict-Transport-Security: max-age=31536000; includeSubDomains
=> Recv header: X-Content-Type-Options: nosniff
=> Recv header: Date: Wed, 08 Jun 2022 16:55:15 GMT
=> Recv header: Connection: close
=> Recv header: Content-Length: 494
=> Recv header:
=> Recv data: {"error":{"code":"AuthorizationFailed","message":"The client 'xxx' with object id '7-----x' does not have authorization to perform action 'Microsoft.RecoveryServices/vaults/backupProtectedItems/read' over scope '/subscriptions/f---1/resourcegroups/ABC/providers/Microsoft.RecoveryServices/vaults/vault-abc' or the scope is invalid. If access was recently granted, please refresh your credentials."}}
I followed every doc I could find but I’m guessing and also tested I get a token following this link https://docs.microsoft.com/en-us/azure/active-directory/develop/v1-oauth2-client-creds-grant-flow
if I do a curl
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'client_id=xxxx&scope=https%3A%2F%2Fmanagement.azure.com%2F.default&client_secret=sssss&grant_type=client_credentials' 'https://login.microsoftonline.com/mytenant.onmicrosoft.com/oauth2/v2.0/token'
with the management scope, not the graph one, I get the bearer token
when I do the curl to list the vault for example from the api
curl -X GET -H "Authorization: Bearer ey…." 'https://management.azure.com/subscriptions/f---1/resourceGroups/ABC/providers/Microsoft.RecoveryServices/vaults/vault-abc?api-version=2016-06-01'
(as documented here Vaults - Get - REST API (Azure Recovery Services) | Microsoft Docs) I get the same error message that I don't have the authorization)
so i’m probably doing something wrong somewhere. I have coded a few custom office365 script in the past using this kind of api access with an app and a secret (or a certificate that worked better).
I’m guessing it’s something about roles, but I don’t understand that part, the oauth2 doc talks about role-less app, maybe it’s that
Do I miss some api rights ?
Do i need to use AZ Cli instead of API
is there a better documentation from centreon somewhere I couldn’t find?
thanks in advance, any input appreciated