user22693343
user22693343

Reputation: 11

Webhook validation fails with Unauthorized

I am trying dynamic configuration using push refresh in Java spring App, for that I am creating Event grid subscription, and while deploying the web-hook URL in azure portal for my application which is deployed in azure web app, I am getting Unauthorized error and deployment of webhook fails

{"code":"Url validation","message":"Webhook validation handshake failed for https://abc.azurewebsites.net/actuator/appconfiguration-refresh. Http POST request retuned 2XX response with response body Unauthorized. When a validation request is accepted without validation code in the response body, Http GET is expected on the validation url included in the validation event(within 10 minutes). For troublehooting, visit https://aka.ms/esvalidation."}

Refered docs: https://learn.microsoft.com/en-us/azure/azure-app-configuration/enable-dynamic-configuration-java-spring-push-refresh?tabs=spring-boot-2%2Ccmd

On webhook deployment why it is giving unauthorized, ideally we are using User-assigned Managed identity, and when we try with connection string still it fails

Upvotes: 1

Views: 449

Answers (1)

mrm9084
mrm9084

Reputation: 493

The method used in the library is a Web Hook based refresh supported by Azure Event Grid, which doesn't support authentication. See https://learn.microsoft.com/en-us/azure/event-grid/handler-event-hubs for details, a link to this can also be found in the push refresh doc linked above.

The App Configuration library added an expected key/value to be set which is included in the web hook request to validate the connection, this also makes it so this endpoint will not trigger a refresh if anyone hits it without those values.

If you are looking for a more custimization you can use any of the Azure Event grid methods to trigger a refresh using spring-cloud-actuator, which has a /refresh endpoint which can be enabled so that can trigger a refresh. Note: This will always force a refresh no mater what has changed.

Or, if you want a more code based solution you can use ApplicationEventPublisher to publish a RefreshEvent which also force triggers a refresh, these are build into Spring Framework.

Upvotes: 1

Related Questions