In the last a couple of months, we had 2 incidents where Azure Document
Intelligence Service in East US region has degraded performance. Because of
that, we were getting a lot of 503s (Service Unavailable) while doing various
operations and our retries didn't help. Microsoft acknowledged the service
degradations.
In a previous post, I wrote about Exposing Azure Document Intelligence Service through Azure Front Door.
In this post, let's see how we can expose secondary Azure Document
Intelligence Services through Azure Front Door.
We can add another Origin to the Origin Group that contains Document
Intelligence Service. But then there is an important factor, from the consumer
side we can't use the Ocp-Apim-Subscription-Key for authentication. That's because we won't know to which origin the traffic
will get routed to and different Document Intelligence services will have
different keys.
So we need to have a shared authentication mechanism for all our consumers and
it can be achieved by using Managed Identities. And using keys (Ocp-Apim-Subscription-Key) is not recommended anyway and we need to be using Managed Identities as much as possible.
We can implement the authentication at 2 places. Either the consumer
authenticate the request or we can have the AFD Origin Group do the
authentication on behalf of the consumer before routing the request to a Origin.
For both these approaches, we need to have a managed identity created, and for
that identity given role Cognitive Services User at both Document Intelligence services.
Consumer authenticating the request against Document Intelligence Services
Here we are making the authentication at the Consumer level using the Managed
Identity. This is helpful when you are consuming the Document Intelligence
service through a SDK.
For an example, if you are using Azure.AI.DocumentIntelligence package,
var documentIntelligenceClient =
new DocumentIntelligenceClient(new Uri("<ENDPOINT>"), new DefaultAzureCredential());
With this ManagedIdentityCredential will be attempted and a token will get retrieved as long as you have
necessary the environment variables set.
Azure Front Door authenticating the request against Document Intelligence Services
|
AFD authenticating the request against Document Intelligence Services |
For that first we need to assign the identity to AFD.
Happy Coding,
Regards,
Jaliya
No comments:
Post a Comment