Recently during an integration scenario with D365 Field services in order to identify if the person making a change to the Customer asset is an employee or not we spinned up an Azure Face API service and on trying to connect it from an Azure function we were getting Invalid key exception.
We were using the Face API client library which defaults to west US endpoint of the service but our service was in EastUS.
Default endpoint:https://westus.api.cognitive.microsoft.com/face/v1.0/
The solution is to override the endpoint tohttps://eastus.api.cognitive.microsoft.com/face/v1.0/ which can be done by using another constructor of the FaceServiceClient class
FaceServiceAPIClient = new FaceServiceClient("Face API subscription key", "https://eastus.api.cognitive.microsoft.com/face/v1.0");