Sociologix
← Latest in AI

AI agents · · 5 min read

Azure AI Search and Claude citations: build a source-backed answer

Explore Microsoft's classic RAG sample, try a minimal Claude citation request, and connect retrieval without losing document permissions.

By Sociologix Editorial

The official Azure Samples classic RAG repository on GitHub.
Microsoft’s Azure AI Search classic RAG repository on GitHub. Preview captured September 19, 2026; repository activity can change.Image source ↗

Separate retrieval from answer generation

A company assistant needs two things to work: it must retrieve the right authorized passage, then produce an answer the reader can check. Azure AI Search and Claude's citation support address different parts of that pipeline. This guide shows where to start with the actual tools, rather than assuming a chat interface makes company knowledge searchable.

This is a documentation-based implementation guide, checked on September 19, 2026. We have not benchmarked the combined pipeline or deployed it for a client. Microsoft's sample uses Azure OpenAI; the Claude step below is a separate adaptation, not an unmodified feature of that repository. [1][2]

1. Start with Microsoft's classic RAG repository

Clone Azure-Samples/azure-search-classic-rag and open its numbered notebooks in Visual Studio Code or your preferred notebook environment. Create a virtual environment and install the repository's requirements. The sample uses NASA material, so you can explore retrieval without uploading private business files. [1]

Begin with 1-introduction-and-setup.ipynb for the Azure resources, model deployments, endpoints, and identity requirements. Continue through 2-build-the-pipeline.ipynb to populate the index, then 3-search-and-generate-answers.ipynb to inspect retrieval and generation. The setup assumes Azure OpenAI embeddings and chat; changing the answer model does not replace the embedding pipeline. [2]

Microsoft now recommends agentic retrieval for modern RAG workloads. The classic sample remains useful for understanding an explicit search-then-answer flow and for existing systems that need fewer changes. Choose the architecture deliberately instead of interpreting this tutorial as a recommendation to use classic RAG everywhere. [1]

git clone https://github.com/Azure-Samples/azure-search-classic-rag.git
cd azure-search-classic-rag
python -m venv .venv
# Activate .venv using your shell, then:
python -m pip install -r requirements.txt

2. Test citations before connecting the search index

First isolate the answer-generation step. Use Python 3.10 or later, run python -m pip install anthropic, and configure ANTHROPIC_API_KEY in your local environment or secret manager. The client reads that environment variable. Keep the key out of the script and source control. [4]

Save the following as citation_demo.py and run python citation_demo.py. It uses claude-opus-5, the model shown in Anthropic's current citation example. The tiny policy is invented test data. The request needs API access and may incur usage charges; it does not create Azure resources. [3]

The SDK returns text blocks with citation objects when supported passages are cited. This example prints both, making it easy to inspect the evidence before building a user interface. [3]

from anthropic import Anthropic

response = Anthropic().messages.create(
    model="claude-opus-5",
    max_tokens=512,
    system="Answer only from the supplied document and cite support. "
           "Say when the document does not answer the question.",
    messages=[{"role": "user", "content": [
        {"type": "document", "title": "Demo onboarding policy",
         "source": {"type": "text", "media_type": "text/plain",
                    "data": "Before kickoff, collect the signed scope "
                            "and the client's technical contact."},
         "citations": {"enabled": True}},
        {"type": "text", "text": "What is required before kickoff?"}
    ]}]
)
for block in response.content:
    if block.type == "text":
        print(block.text)
        for citation in block.citations or []:
            print("Source:", citation.cited_text)

3. Replace the demo document with retrieved passages

After the standalone example works, adapt the final generation step of the Azure sample. Build document blocks from the authorized search results instead of sending the hard-coded policy. Keep a mapping between each document's position in the request and its original source record.

Preserve the source title, version, and canonical location in your application. Render the returned citation beside the sentence it supports and open the relevant passage when selected. Avoid letting generated text choose arbitrary destination URLs. A citation should resolve through your stored source mapping.

Inspect retrieval output before changing the prompt. If the relevant paragraph never reached the model, more confident instructions cannot recover it. Compare keyword phrasing, document chunk boundaries, and the indexed version.

4. Enforce permissions before the model sees the text

The repository explicitly omits per-user security trimming. Do not connect its basic sample to unrestricted internal documents and assume login alone protects the answers. [1]

Microsoft documents security filters that compare a caller's user or group identifiers with indexed permissions. It also lists native document-permission integrations with preview limitations. Choose the appropriate mechanism for your environment and enforce it in the retrieval path. [5]

Resolve identity on the server. Recheck access when opening a source, and consider permission changes in stored conversations and caches. Test two accounts with different access; an answer must not reveal content the second account could not retrieve.

5. Debug missing and unsupported answers

Make a small test set with an answerable question, a missing policy, an outdated document, and a restricted source. Save the question, permitted results, answer, and citations together during evaluation.

If no citation appears, inspect whether the supplied text actually supports the question. Anthropic currently cannot combine citations with its structured-output format setting, so keep that setting out of this request. [3]

When evidence is absent, show a clear no-answer state and a useful next step, such as contacting the document owner. Improve the source collection or retrieval before expanding the assistant's responsibilities.

Sources & further reading

  1. Microsoft — Azure AI Search classic RAG sample
  2. Microsoft — Classic RAG introduction and setup notebook
  3. Anthropic — Citations
  4. Anthropic — Python SDK setup
  5. Microsoft Learn — Document-level access control in Azure AI Search

Build an assistant that can show its working.

Bring Sociologix your document sources, access requirements, and recurring questions. We can help design retrieval, citations, and evaluation around your actual knowledge workflow.

Talk to Sociologix