Testing Azure content filters and Prompt Shields with promptfoo

Azure reports prompt and document attacks through three layers that return different signals. This page shows how to test each layer in promptfoo and read the results without mixing them up.

On this page

How to test Azure content filters and Prompt Shields with promptfoo

A team with Azure guardrails in front of a model or document pipeline needs evidence that those guardrails block attacks without blocking legitimate users. This section explains how to produce that evidence with promptfoo. The key point is that Azure gives you three separate signals: the content filtering applied to Azure OpenAI responses and requests, the severity thresholds in Azure AI Content Safety, and Azure Prompt Shields, which looks for prompt and document attacks. Each can block, flag or pass for different reasons, so a single pass rate hides which layer acted. Plan your test so each layer is measured on its own before you judge the stack as a whole.

Before writing any test, confirm the exact Azure provider and guardrail settings that promptfoo supports in the version you install. The installed version should be 0.124.1 or later and run on Node.js 22.22.0 or newer, but the supported Azure options change between releases, so check the current promptfoo introduction and the provider reference for your version. Record which Azure resource, deployment and API version each test ran against, because a filter change in Azure can alter results without any change in your application. Ask your Azure administrator which filter configuration and severity thresholds are attached to each deployment, and whether Prompt Shields is enabled on the same path your users take.

Write separate test sets for the attack layer and the benign layer, then run each against the Azure path your users actually use, including any document ingestion step. Track errors, timeouts and throttling separately from blocks and passes, since an error is not evidence that a filter worked. Keep the benign set representative of your own traffic, because a filter that looks strict in one language or domain may behave differently in another. The result you need is a per-layer picture of what was blocked, what was wrongly blocked and what got through, which gives you the basis for deciding whether to change a threshold or a setting.

Prerequisites for testing Azure content filters with promptfoo

Most delays in an Azure guardrail test come from access, network and approvals rather than from promptfoo itself. The cards below list what the team should have in place before the first run, so the results reflect the filter under test and nothing about the environment.

Azure resource under test

Identify the exact Azure OpenAI deployment or Azure AI Content Safety resource that carries the content filter or Prompt Shields configuration you plan to test. Record the filter policy, severity thresholds and whether Prompt Shields is attached to that deployment. A test against a resource with different settings from production measures the wrong system, so confirm the configuration is the one users reach.

Red teaming docs

Node.js and promptfoo on the runner

Run promptfoo on a workstation or CI runner with Node.js 22.22.0 or newer. Pin the promptfoo version you test with so results can be reproduced later, and record it alongside each run. Confirm the runner image is one your platform team supports before you add it to a pipeline.

promptfoo on npm

Credentials scoped to test resources

Create Azure credentials that can call only the test deployment or Content Safety resource, not the production subscription. Store keys in your secrets manager and inject them at run time, never in the promptfoo config file. Ask who rotates these keys and how quickly a leaked key can be revoked.

Network paths to Azure endpoints

Confirm the runner can reach the Azure endpoints for the resource over the network path your organization allows, including any private endpoint, proxy or firewall rule. Test connectivity with a single benign request before the full dataset runs. Failures at this layer often look like guardrail errors in the results, so resolve them first.

Written approval for test data

Get written permission to send your attack and benign datasets to Azure. Some prompts contain harmful content, customer-like records or internal material, and the approver should know that Azure will process them under your agreement. Keep the approval with the test plan so auditors and security reviewers can trace what left your environment.

API version and deployment names

Ask the team to confirm which Azure API version and deployment names the promptfoo provider expects for this test. Different API versions can return different filter metadata, and a mismatch can silently change what is measured. Write the confirmed values into the config and note them in the run record before the first scan.

Why Azure content filters and Prompt Shields return different signals

The three Azure controls answer different questions, so a single pass or fail result hides what each one actually decided. Azure OpenAI content filtering runs as part of the model request and response path and reports whether harmful content was detected in the prompt or the completion, by category. Azure AI Content Safety severity thresholds are applied to text or images you send to the service and tell you how severe the content is on a configured scale. Prompt Shields asks a different question: whether a user prompt or a document looks like a jailbreak attempt or an indirect injection, meaning instructions hidden in content the model is asked to process. A prompt can be clean on harm categories, sit below your severity cut-off, and still be flagged as an injection, or the reverse.

That gap has a practical consequence for your test design. Record the outcome of each layer separately for every test case, with the category, severity value or attack flag that layer returned, instead of storing one blocked or allowed field per prompt. If your application only sees the final response, a blocked result may come from any layer, and you will not know which setting to tune. Keep the layer name in the result label so that a regression in Prompt Shields does not get reported as a change in harm-category sensitivity. Test document attacks as their own set, because the behavior for documents embedded in a request can differ from direct user input.

Before you write thresholds into a promptfoo assertion, confirm the current category names, severity scales and document attack behavior in the Azure documentation for your region and API version, since these details change between releases and between deployments. Ask your Azure account team or your own platform owner which content filter configuration is applied to each deployment you test, because a filter attached to a different deployment can make your results look better or worse than production. Once you know which layer produced each signal, you can tune one control at a time and rerun the same attack and benign sets to see its effect.

How a promptfoo test reaches each Azure layer

The test starts in the promptfoo CLI on the team's runner, which sends each test case to the application or to an Azure endpoint. The request then crosses the trust boundary into Azure, where the Azure OpenAI content filter, the Prompt Shields check on prompts and documents, and, where it is used, the Content Safety severity check can each act on it. The response returns to promptfoo, which applies assertions and writes the result to local files. Check which layer produced each block, because the three layers answer different questions.

Each test passes through the Azure layers in order, and the result is written locally.

Configuring the promptfoo test against Azure step by step

This sequence takes you from a working promptfoo install to a configuration that tests each Azure protection layer separately, with datasets and thresholds you can tune. Each step ends with a check that confirms the layer under test is reporting its own result.

  1. Install promptfoo and confirm the version

    The engineer running the test installs the promptfoo CLI on a workstation or CI runner with Node.js 22.22.0 or newer, which is the minimum version listed for the npm release 0.124.1. Record the installed version in your test notes so later results can be reproduced. The step is done when the version command prints a version number and a trivial local eval runs to completion without a provider error. Confirm the requirement against the current release notes before you install, since newer releases may change it.

  2. Create the configuration file for the Azure target

    Write a promptfooconfig.yaml that points at the Azure-backed endpoint under test, such as the Azure OpenAI deployment or the application route that calls it. Keep credentials in environment variables rather than in the file, and name the deployment, API version and region as the Azure resource defines them. Add the prompt template and a single provider entry, and leave the content filter and Prompt Shields settings on the Azure side unchanged so the baseline reflects production. The step is done when promptfoo eval runs one harmless input and returns a response from the Azure target, and you can see which deployment answered.

  3. Build separate benign and attack datasets

    Create two datasets: a benign set of ordinary user prompts and business documents that should pass, and an attack set of direct prompt injections, jailbreak attempts and indirect injections hidden inside documents such as emails, PDFs or retrieved pages. Keep each file in a separate CSV or YAML source so that the pass rate for each side is easy to read. Include a few harmless inputs that look risky on the surface, such as security questions, to surface false positives early. The step is done when both files load and each row has a label stating whether it should be blocked, which you can check by listing the test count per file.

  4. Map one assertion group to each Azure layer

    Define one group of assertions for each layer: one for the Azure OpenAI content filtering that applies to the model response, one for the Azure AI Content Safety severity thresholds on text, and one for Azure Prompt Shields on user prompts and documents. Tag each group with the layer name so the results are reported separately rather than merged into one score. Use the guardrail or not-guardrail assertion types that match how each layer signals a block, and document the signal each layer returns in your notes. The step is done when a dry run lists every test with its layer tag and no test is left without an assertion group.

  5. Run a small batch and confirm layer results

    Run promptfoo eval against a handful of tests, including one known harmless input and one known attack input for each layer. Open the results view or export the output and check that each test shows the layer that produced the decision, with the block or pass recorded under that layer's name. Note any errors, timeouts or rate-limit responses separately from passes and blocks, because an error is not evidence that a filter worked. The step is done when the known harmless input passes every layer, the known attack input is flagged by the layer expected to catch it, and no result is ambiguous.

  6. Expand the datasets and review false positives

    Grow the benign and attack sets to cover the prompts, documents and languages your application actually receives, and rerun the full suite. Review every benign input that was blocked and every attack that passed, and decide whether the fix belongs in a filter setting, the application prompt or the test label. Record which findings are Azure behavior and which are test errors. The step is done when a second run shows the same layer-level results for the reviewed cases, and the open findings are written down with an owner.

  7. Set thresholds and record the baseline

    Choose the pass-rate thresholds for each layer based on the trade-off you accept between missed attacks and wrongly blocked users, and set them in the configuration so a failing run is clear in CI. Confirm the Azure severity settings and Prompt Shields configuration in the Azure resource match what you tested, and record them alongside the promptfoo version and dataset versions. Save this run as the baseline for future comparisons. The step is done when a rerun against the unchanged target meets the thresholds, and a deliberately weakened test input fails the gate as expected.

Mapping each Azure signal to a promptfoo result

This table compares the three Azure layers you will test, what each one decides, and what evidence to store in promptfoo for every case. Read it before writing assertions, because a blocked prompt, a severity score and a shield verdict are different signals and should not be scored the same way.

Azure layerWhat it decidesInput examined and evidence to record in promptfooWhat to confirm with Azure documentation
Azure OpenAI content filteringWhether the model deployment blocks or annotates a request or response in listed harm categories, using the filter configured on the deploymentPrompt and completion. Record the HTTP status or error code, the content filter result fields returned with the response, the filter configuration name, and the test case IDWhich categories and severity levels are returned on your API version, and which responses are blocked versus only annotated
Azure AI Content Safety severity thresholdsA severity score per harm category for text or image input, which your own code compares against a threshold you choosePrompt, completion or document text sent to the analysis call. Record each category score, the threshold used, the resulting pass or fail, and the API versionThe severity scale and value ranges for your API version, and whether scores are comparable across categories and languages
Prompt Shields for user prompt attacksWhether a user prompt looks like a jailbreak or prompt injection attempt, returned as a detection flagUser prompt only. Record the detected flag, the attack label used in the dataset, the expected outcome, and the raw response bodyWhich attack types are detected, supported languages, and whether the flag is a verdict or a probability you must threshold
Prompt Shields for document attacksWhether a document or grounding source given to the model contains embedded instructions or indirect injectionDocument text supplied in the request, with the document ID or source label. Record the detection flag, the document hash, and the downstream model outputSupported document formats and size limits, and whether the check runs on retrieved content or only on fields you pass in
Interpreting a passEach layer answers a different question, so a single test case can pass one layer and fail anotherStore results per layer rather than one combined verdict, so a filter block is not counted as a shield detection in the reportWhether a blocked response is returned as an error, a filtered finish reason, or a normal response with annotations

Common questions about testing Azure filters with promptfoo

What drives the cost of testing Azure content filters with promptfoo?

The effort follows the number of Azure layers under test, the size and mix of your datasets, the document types you need to cover, the number of environments, and whether results must be reviewed by security or compliance. Each Azure layer (the Azure OpenAI content filter, Azure AI Content Safety severity thresholds, and Prompt Shields) needs its own configuration, its own request path and its own assertions, so adding a layer adds work. Attack and benign datasets grow the run time and the review effort, and document-based attacks need a separate ingestion path from plain prompts. Each environment needs its own configuration and checks. If security or compliance must sign off, expect more time for evidence capture and review. Ask any provider for a written scope listing these items, the deliverables and the acceptance criteria before you compare quotes.

How long does a first Azure filter test cycle take?

The duration depends on how much of the setup already exists and how quickly decisions are made. The main drivers are access to the Azure resources and the test environment, approval of test data, the number of filter layers in scope, and how many threshold decisions must be taken before the test results are useful. Teams that already run promptfoo against an Azure OpenAI deployment usually spend less time on connection setup than teams starting from nothing. Document attack testing usually takes longer than prompt-only testing because the documents must be prepared, labeled and reviewed. Ask for a timeline tied to these named dependencies in the written scope rather than a single number.

What must our team provide before testing starts?

Three things unblock most engagements: access to the Azure resources under test, approved test data, and a named owner for threshold decisions. Access usually means a deployment that the test runner can call with a key or identity that has the right scope, plus read access to the filter configuration so the results can be tied to actual settings. Test data needs approval from the data owner and, for regulated content, from security or legal, because attack prompts and sample documents can contain sensitive material. The threshold owner decides which severity levels block content and which only flag it, and that decision needs a person who can accept the trade-off between missed attacks and wrongly blocked users. Confirm with your Azure administrator which subscription, region and resource names apply before the work begins.

Can an internal team test Azure filters with promptfoo alone?

Yes, an internal team with Azure and Node.js experience can run promptfoo locally and write its own configuration, because the open-source tool runs on your machine and calls the model endpoints directly. The harder parts are usually outside the tool: deciding which thresholds are acceptable, building a benign dataset that reflects real users, interpreting why Prompt Shields and the content filter disagree on the same input, and producing evidence that a security reviewer will accept. Teams often ask for outside help at those points, or when they need the same suite to run in several environments and be reviewed on a schedule. A fixed-scope engagement can cover the setup, the first test cycle and the handover, leaving your team to run the suite afterward.

Does free promptfoo cover Azure filter testing, or do we need Enterprise?

The free Community edition is enough to run evaluations and red teaming against Azure endpoints, because promptfoo's documentation states that evals run on your machine and talk directly with the LLM, and the Community edition includes all LLM evaluation features, all model providers and integrations, and red teaming with 10k probes per month. Enterprise becomes relevant when you need team sharing, teams-based access control and SSO, a centralized guardrail dashboard, continuous monitoring or priority support with SLAs. The self-hosted promptfoo app stores data in a local SQLite database without RBAC or built-in SSO and is not recommended for production use, so a shared team deployment needs a different plan. Check current terms on the promptfoo pricing page, since Enterprise pricing is custom.

Will a passing Azure filter test prove we are compliant?

No. A passing test shows that the configured filters behaved as expected against the datasets you ran on the day you ran them. It does not establish compliance on its own, and it does not replace an assessment by an independent auditor or certification body. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports or attestations. Ask whether your framework requires evidence of ongoing monitoring, change control for filter settings, and documented threshold decisions, since those need processes beyond a single test run. Confirm the requirements with your compliance lead before you agree on the evidence the engagement will produce.

How do Azure filter tests differ from testing our own application?

Azure filter testing measures the service-level decisions that Azure returns, while application testing measures what your product does with those decisions. A filter can block a request that your application would have handled safely, or pass content that your application then mishandles, so both levels need tests. Ask your team to decide which level answers the question they are asking before writing datasets, because the expected results and the owners of a failure differ. Confirm with Azure documentation which filter configuration applies to each deployment, since the same model can behave differently under different filter settings.

Securing Azure filter tests in promptfoo

Azure filter tests send attack prompts and documents through a live Azure resource, and the results often contain the same sensitive content. The controls below cover how credentials are held, what identity runs the tests, where data goes, and how the self-hosted promptfoo server is fenced in for a team.

Keep Azure keys out of config files

Store the Azure OpenAI and Azure AI Content Safety keys in a secrets manager and inject them as environment variables when the run starts. A promptfoo configuration file that names a key value will be committed to source control sooner or later, and a leaked key lets anyone call your filter resource at your cost. Check that the repository scanner and the CI logs both mask these variables, and that the config references only variable names.

Scope the test identity tightly

Give the test identity access only to the test Azure resource that hosts the content filter and Prompt Shields deployment, not to production subscriptions or shared resource groups. Prefer a dedicated resource and a role limited to the data-plane actions the tests need. Confirm with Microsoft's current documentation which role names cover content safety calls, because role definitions change.

Decide where attack data may go

Attack datasets and results can leave the runner in two directions: to the Azure endpoint that scores them, and to any storage or reporting service you send results to. Write down which of those destinations your security and privacy teams have approved, and whether the Azure resource's data handling terms cover adversarial prompts. promptfoo runs locally and talks directly with the model, so the policy decision sits with your team.

Plan around single-instance server limits

The self-hosted promptfoo app stores data in a local SQLite database that cannot be shared across replicas. It also has no RBAC, horizontal scaling, built-in authentication or SSO, and the project does not recommend it for production. Run one instance, place it behind your existing access proxy or identity layer, and restrict network access to the team that needs it. Teams needing SSO and role-based access should review the Enterprise options instead.

Self-hosting docs

Treat stored attack prompts as sensitive

A Prompt Shields or content filter dataset is effectively a playbook for bypassing your own controls, and its results show which attacks worked. Store both with the same classification as security test reports, restrict read access, and set a retention period your policy defines. Avoid copying them into general-purpose chat tools or shared spreadsheets. Remove them from the self-hosted database or exported files when the test cycle ends.

Reading the results without overstating a pass

A passing run proves only what the chosen datasets exercised. If a Prompt Shields suite contains a small set of document attacks, a clean result shows that those specific documents were blocked under those settings, not that every indirect injection through a document is stopped. Write the claim the way the data supports it: which attack categories, which languages and document formats, how many cases per category, and which Azure resource and filter configuration were in place. Treat the pass rate as a measurement of that dataset, and plan additional cases for the document types your application actually ingests, such as PDFs with hidden text, scanned images or long files that exceed what you tested.

Run the benign set in the same pass and count every blocked benign request as a false positive, using the same assertions and reporting path as the attack results. A content filter that blocks every attack but also blocks ordinary support tickets, medical terms or customer complaints has not passed in any sense your users would accept. Keep errors separate from passes and failures. A timeout, a rate-limit or quota response, or a malformed response from the Azure endpoint is not a successful block, and it is not a clean result either. Report these as a distinct error count, rerun the affected cases, and make sure a run with many errors cannot be read as a high pass rate.

Record enough detail that someone else can repeat the run and get comparable output. At minimum, capture the promptfoo version (the npm release 0.124.1, published on 8 October 2026, is one example of a version to pin and record), the Node.js version, the dataset file hashes, the Azure resource, region, API version and the content filter and Prompt Shields settings in effect, including severity thresholds. Confirm current API versions and setting names with Microsoft's documentation and your own Azure tenant before writing them into a report. Finally, treat this output as engineering evidence for your security and compliance teams. It supports a review but is not an audit report or a certification, and an independent assessor will decide what it is worth for your framework.

Troubleshooting Azure Prompt Shields and content filter tests

This table pairs common failure points in Azure content filter and Prompt Shields tests with their likely causes and fixes. Use it to separate guardrail decisions from errors before you read pass rates. Confirm each fix against the current Azure and promptfoo documentation, since API behavior and provider settings change.

SymptomLikely causeFix
A layer returns no result for a test caseThe request never reached that layer, for example because an earlier filter or the application short-circuited the callLog the request path for each case, confirm which layer was called, and mark cases that never reached a layer as errors rather than passes
Filtered responses are counted as provider errorsThe test treats a blocked response as a failed API call instead of a guardrail decisionCheck how the Azure response reports a filtered prompt or completion and map it to a guardrail flag in your assertions, keeping it separate from error counts
Document attack tests fail before the shield runsThe file type, file size or encoding falls outside what the Prompt Shields document input acceptsConfirm the supported formats and size limits in Azure documentation, then check your fixtures against them before reading any detection result
Severity results differ between runs or environmentsThe API version, region or model deployment differs from the one used in an earlier runPin the API version and region in the provider config, and rerun a fixed sample on each environment before comparing thresholds
Credentials work for one resource but not anotherKeys, endpoints or deployment names belong to different Azure resources, or the environment variables point at the wrong oneList each resource's endpoint and deployment name in the config, load keys per resource, and test each one with a single known-safe request
Results cannot be compared across runsThe Azure settings used for the run, such as filter configuration, thresholds, API version and deployment, were not recordedWrite the provider configuration and resource identifiers into every results file, and treat runs without that record as non-comparable

How DeployOpen works on this

DeployOpen scopes Azure guardrail testing as a written, fixed-scope engagement that sets out which filters, severity thresholds and Prompt Shields paths are tested and how results are reported. The work is delivered inside your own Azure and application environment, with the promptfoo suites, evidence and handover documented for your team.

How we scope

  • Confirm which Azure OpenAI deployments, content filter configurations and Prompt Shields endpoints are in the test boundary
  • Agree the attack and benign datasets, the severity thresholds to measure, and the application paths to test
  • Record in the written scope how false positives, missed attacks and errors will be reported separately

How we build

  • Build promptfoo configurations that run against your Azure resources with credentials kept in your own secret store
  • Write assertions that separate guardrail blocks, filter annotations and provider errors so results are not conflated
  • Test direct prompt attacks and indirect document attacks, then retest after each agreed fix or filter change

How we hand over

  • Deliver the promptfoo configs, datasets and run instructions in a repository your team controls
  • Provide a findings report with reproducible test cases, severity, recommended filter settings and a retest record
  • Walk your security and platform engineers through how to rerun the suites and read the output

How we support

  • Offer ongoing support, upgrades of promptfoo and continuous testing as a retainer after the fixed-scope work
  • Re-run the suites when Azure filter defaults, model deployments or application prompts change
  • Confirm support terms, response expectations and any SLA in the written agreement before work starts

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.