Azure / Azure/apiops

[BUG] Issues with EventHub Logger configured using System Assigned Managed Identity

Aperta
#344 22 commenti 0 reazioni 1 assegnatario Rivendicata da @guythetechie Vedi su GitHub
bug
Lingua principale
C#
Stelle
448
Fork
247
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### Release version

v4.5.0

### Describe the bug

We have configured the event hub logger for apim using the system-assigned identity. While running the Publisher to Dev environment is failing with the below exception on the EH logger. I could not able to find any reference in the documentation around eventhub setup using system identity; the wiki and few other issues reported on logger were talking about the logger configured using the connectionString.

exception log:

System.Net.Http.HttpRequestException: HTTP request to URI https://management.azure.com/subscriptions/***/resourceGroups/**-int-dv-apim-rg/providers/Microsoft.ApiManagement/service/**-int-dv-apim/loggers/apim-dv-eventhub-logger?api-version=2022-04-01-preview failed with status code 400. Content is '{"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"One or more Properties ['{0}'] specified are missing.","message":"64c7d150fb42680fe*******"}]}}'.

We noticed when the extractor ran that the associated extracted json for the logger only contains the following
loggerInformation.json, but it was missing the other properties within the credentials.

```
`{
"properties": {
"credentials": {
"name": "i**-mgmt-pr-evh-02"
},
"description": "adding a new logger with system assigned managed identity",
"isBuffered": true,
"loggerType": "azureEventHub"
}
}`
```
With the above-extracted json, we noticed the publisher to dev was failing with the missing connectionString property was missing; since we did not use connectionstring to set up the logger and it was using the system identity. I tried to update the JSON logger as below by adding the endpoint and identityClientID (generated named value for the logger), but it failed with the error mentioned in the exception log above.

loggerInformation_manual_update.json
```

`{
"properties": {
"credentials": {
"identityClientId": "{{64c7d150fb42680**********}}",
"name": "***-mgmt-pr-evh-02",
"endpointAddress": "***-mgmt-pr-evhns.servicebus.windows.net/***-mgmt-pr-evh-02"
},
"description": "adding a new logger with system assigned managed identity",
"isBuffered": true,
"loggerType": "azureEventHub"
}
}`
```

Documentation referred for setting up EH logger using system identity https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-log-event-hubs?tabs=PowerShell#logger-with-system-assigned-managed-identity-credentials

a

### Expected behavior

We expect the publisher to dev environment should not fail while pushing the changes back to Dev environment and eventually to higher environments

### Actual behavior

System.Net.Http.HttpRequestException: HTTP request to URI https://management.azure.com/subscriptions/***/resourceGroups/gi-int-dv-apim-rg/providers/Microsoft.ApiManagement/service/gi-int-dv-apim/loggers/apim-dv-eventhub-logger?api-version=2022-04-01-preview failed with status code 400. Content is '{"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"One or more Properties ['{0}'] specified are missing.","message":"64c7d150fb42680fe4*****"}]}}'.

### Reproduction Steps

1. EH logger added using system identity for steps mentioned here https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-log-event-hubs?tabs=PowerShell#logger-with-system-assigned-managed-identity-credentials
2. Ran extractor and publisher job. Publisher was using the json file loggerInformation.json, where the publisher fails on missing connectionstring property
3. Manually updated the loggerInformation.json, see above mentioned block for loggerInformation_manual_update.json, where with this config, publisher has failed with the exception as provided above

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.