I am trying to use azure's document analysis client but I don't use credentials for my form recognizer. I can make a simple request call to it and it works fine, like so:
import requests
my_endpoint = "http://form_recognizer...?api-version=2022-08-31"
data = "some data"
params = "some params"
requests.post(my_endpoint, headers={'Content-Type': 'application/octet-stream'}, data=data, params=params)
The request works and it gives me the results I need. However, I would prefer to use DocumentAnalysisClient
because it comes with several methods that would save me weeks of coding. However, this class requires a credential
argument but I am not using credentials for this endpoint. It is an open HTTP endpoint, so how exactly can I use the class without providing any credentials?
from azure.ai.formrecognizer import DocumentAnalysisClient
client = DcoumentAnalysisClient(endpoint=my_endpoint, credential=...)
Can I use Azure DocumentAnalysisClient with no credentials?
According to this MS-Document, it is not possible to access DocumentAnalysisClient
without credentials.
The DocumentAnalysisClient
requires a credential to authenticate with the Azure service, either with AzureKeyCredential
or Azure Active Directory credential
.
For key credential, you need to pass the key
of your Document intelligence AI service.
Code:
from azure.ai.formrecognizer import DocumentAnalysisClient
from azure.core.credentials import AzureKeyCredential
endpoint = "<Your-endpoint>"
credential = AzureKeyCredential("")
client = DocumentAnalysisClient(endpoint=endpoint, credential=credential)
For Active Directory credential, you need to use azure-identity to authenticate with Document intelligence AI service.
Code:
from azure.ai.formrecognizer import DocumentAnalysisClient
from azure.identity import DefaultAzureCredential
endpoint = "<Your-Endpoint>"
credential = DefaultAzureCredential()
client = DocumentAnalysisClient(endpoint, credential)
Now, using the above authentication process, you can build all intelligent document processing solutions.