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.
2,026 questions
{count} votes

2 answers

Sort by: Most helpful
  1. navba-MSFT 27,515 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.


  2. Ubana, Siddharth 20 Reputation points
    2025-04-28T11:12:58.3366667+00:00

    Please use below code for analyzing data using query fields. This is working for Azure.AI.DocumentIntelligence v1.0.0.

    //Content is a byte array containing document data
    BinaryData data = BinaryData.FromBytes(Content);
    
    var analyzeOptions = new AnalyzeDocumentOptions(modelId, data) 
    { 
      Pages = "1-2", 
      Features = { DocumentAnalysisFeature.QueryFields }, 
      QueryFields = { "FullName", "CompanyName", "JobTitle" } 
    };
    
    Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, analyzeOptions);
    
    AnalyzeResult result = operation.Value;
    
    
    0 comments No comments

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.