Skip to content

Commit 1e4916c

Browse files
Merge pull request #314102 from lilyjma/update-disable-key
Set key-based access to anonymous using app setting instead
2 parents d5e2360 + b906fdb commit 1e4916c

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

articles/azure-functions/functions-mcp-tutorial.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ There are two ways to reduce or prevent unauthorized use of your remote MCP serv
288288
::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript"
289289
## Disable key-based authentication
290290

291-
The built-in server authorization feature is a component separate from Azure Functions. When using server authentication, it's best to first disable key-based authentication by allowing anonymous access.
291+
The built-in server authorization feature is a component separate from Azure Functions. When using server authentication, disable key-based authentication by allowing anonymous access first.
292292

293293
### [MCP extension server](#tab/mcp-extension)
294294

@@ -368,6 +368,16 @@ When deployment finishes, you should see a notification in Visual Studio Code ab
368368

369369
The following instruction shows how to enable the built-in authorization and authentication feature on the server app and configures Microsoft Entra ID as the identity provider. When done, you test by connecting to the server in Visual Studio Code and see that you're prompted to authenticate before connecting.
370370
371+
When enabling built-in auth, you should [disable the default key-based auth](#disable-key-based-authentication) first. If you haven't done that and your app is already deployed, follow the instructions below.
372+
373+
### [MCP extension server](#tab/mcp-extension)
374+
[!INCLUDE [functions-mcp-extension-disable-key-access](../../includes/functions-mcp-extension-disable-key-access.md)]
375+
376+
### [Self-hosted server](#tab/self-hosted)
377+
[!INCLUDE [functions-self-hosted-disable-key-access](../../includes/functions-self-hosted-disable-key-access.md)]
378+
379+
---
380+
371381
### Configure authentication on server app
372382

373383
1. Open the server app on the Azure portal, and select **Settings** > **Authentication** from the left menu.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
author: lilyjma
3+
ms.service: azure-functions
4+
ms.topic: include
5+
ms.date: 04/01/2026
6+
ms.author: jiayma
7+
---
8+
9+
To disable host-based authentication in your self-hosted MCP server, add a setting named `AzureFunctionsJobHost__customHandler__http__DefaultAuthorizationLevel` with a value of `anonymous` to your application settings. You can add this setting in the portal or use the following Azure CLI command:
10+
11+
```azurecli
12+
az functionapp config appsettings set --name <APP_NAME> --resource-group <RESOURCE_GROUP> \
13+
--settings "AzureFunctionsJobHost__customHandler__http__DefaultAuthorizationLevel=Anonymous"
14+
```
15+
16+
In this example, replace `<APP_NAME>` and `<RESOURCE_GROUP>` with the name of your function app and resource group.
17+
18+
>[!TIP]
19+
>This setting is equivalent to setting `DefaultAuthorizationLevel` to `anonymous` in the `customHandler` section of the `host.json` file. However, that method requires you to republish your server project.

0 commit comments

Comments
 (0)