does SDK c# support add-on query field ( Document intelligence)

Khadija Alaqra 0 Reputation points
2024-06-29T18:44:30.8333333+00:00

Hi everyone,

I'm trying to use the Azure Document intelligence prebuilt model (invoice) to read and extract specific fields , I read the document of Microsoft to see some examples how to add-onn field query to the request using c# sdk , but I only found a code in python . My question is : does the c# sdk support the add-on query fields or not ? and if yes , could u plz provide me with some examples that might help me ?

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

1 answer

Sort by: Most helpful
  1. navba-MSFT 27,470 Reputation points Microsoft Employee
    2024-07-01T05:55:55.13+00:00

    @Khadija Alaqra Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    Yes, the SDK has the support for QueryFields feature.

    The following add-on capabilities are available for2024-02-29-preview and later releases:

    .

    Please note that Query fields: query fields are reintroduced as a premium add-on feature. When the DocumentAnalysisFeature.QueryFields argument is passed to a document analysis request, the service will further extract the values of the fields specified via the parameter queryFields to supplement any existing fields defined by the model as fallback.

    .

    Suggestions:

    You need to use one of the overloads of DocumentIntelligenceClient.AnalyzeDocumentAsync Method by passing the DocumentAnalysisFeature.QueryFields Property.

    More info here: https://learn.microsoft.com/en-us/dotnet/api/azure.ai.documentintelligence.documentanalysisfeature.queryfields?view=azure-dotnet-preview

    Sample code snippet here:

    Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(
        WaitUntil.Completed,
        "prebuilt-receipt",
        new AnalyzeDocumentContent
        {
            Base64Source = new BinaryData(dbScanToWs.RelatedPDFs[i])
        },
        queryFields: new List<string> { "TaxDetails_TaxAmount", "TaxDetails_TaxNetPercentage" },
        features: new List<DocumentAnalysisFeature> { DocumentAnalysisFeature.QueryFields });
    AnalyzeResult receipts = operation.Value;
    

    Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.

    **

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.