How to access url with authentication from Form Recognizer?

ARIJIT Dutta (IN) 5 Reputation points
2023-04-03T10:39:00.55+00:00

I am trying to access a pdf file which does not have public access. I have the credentials needed to access the file. Does Azure Form Recognizer have any option to send in the required credentials along with the file URL for accessing the document ?

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,451 questions
{count} vote

2 answers

Sort by: Most helpful
  1. VasaviLankipalle-MSFT 15,006 Reputation points
    2023-04-03T23:21:35.47+00:00

    Hi @ARIJIT Dutta (IN) , Thanks for using Microsoft Q&A Platform. I don't believe Azure Form Recognizer have an option to send in credentials along with the file URL for accessing the document. However, you can use Azure Blob Storage to store your PDF files and set up an access policy that allows you to provide credentials to access the files. Here's how you can try:

    1. Create an Azure Blob Storage account and upload your PDF files to a container in the storage account.
    2. Try setting up an access policy for the container that requires credentials to access the files. You can do this by creating a Shared Access Signature (SAS) token with the required permissions and expiry time. You can then append the SAS token to the URL of the PDF file to access it.
    3. Then use the Azure Form Recognizer API to extract data from the PDF file by providing the URL of the file with the appended SAS token.

    You can refer to the following documentation to know how to create SAS tokens for storage containers: https://learn.microsoft.com/en-us/azure/applied-ai-services/form-recognizer/create-sas-tokens?view=form-recog-3.0.0

    I hope this helps. Let me know if you need more information.

    -Please kindly accept the answer and vote 'Yes' if you feel helpful to support the community, thanks.


  2. Arturs Klesuns 5 Reputation points
    2023-08-08T13:01:23.1333333+00:00

    You can actually just send the file itself in the analyze request instead of making it accessible via a public URL. See this SO answer.

    curl -i https://{endpoint}/formrecognizer/v2.1-preview.3/custom/models/{modelId}/analyze -H 'Content-Type: application/pdf' \
      -H 'Ocp-Apim-Subscription-Key: {subscription key}' --data-binary @/path/to/your/file.pdf
    
    0 comments No comments