Skip to content

Commit ebeea88

Browse files
authored
Merge pull request #302621 from TimShererWithAquent/us446746-05
Freshness Edit: Azure Functions
2 parents 24c2998 + f481299 commit ebeea88

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

articles/azure-functions/function-keys-how-to.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ title: Work with access keys in Azure Functions
33
description: Learn about access keys in Azure Functions, including how to get and renew keys and how to use access keys when calling function endpoints.
44
ms.service: azure-functions
55
ms.topic: how-to
6-
ms.date: 07/18/2024
6+
ms.date: 07/13/2025
77

88
#CustomerIntent: As an Azure Functions developer, I want learn how to work with access keys so that I can properly harden both my function endpoints and my overall function app running in Azure.
99
---
1010

1111
# Work with access keys in Azure Functions
1212

13-
Azure Functions lets you use secret keys to make it more difficult to access your function endpoints. This article describes the various kinds of access keys supported by Functions, and how to work with access keys.
13+
Azure Functions lets you use secret keys to make it more difficult to access your function endpoints. This article describes the kinds of access keys that Functions supports, and how to work with access keys.
1414

1515
While access keys provide some mitigation against unwanted access, you should consider other options to secure HTTP endpoints in production. For example, it's not a good practice to distribute shared secrets in a public app. If your function is being called from a public client, you should consider implementing these or other security mechanisms:
1616

17-
+ [Enable App Service Authentication/Authorization](security-concepts.md#enable-app-service-authenticationauthorization)
18-
+ [Use Azure API Management (APIM) to authenticate requests](security-concepts.md#use-azure-api-management-apim-to-authenticate-requests)
19-
+ [Deploy your function app to a virtual network](security-concepts.md#deploy-your-function-app-to-a-virtual-network)
20-
+ [Deploy your function app in isolation](security-concepts.md#deploy-your-function-app-in-isolation)
17+
- [Enable App Service Authentication/Authorization](security-concepts.md#enable-app-service-authenticationauthorization)
18+
- [Use Azure API Management (APIM) to authenticate requests](security-concepts.md#use-azure-api-management-apim-to-authenticate-requests)
19+
- [Deploy your function app to a virtual network](security-concepts.md#deploy-your-function-app-to-a-virtual-network)
20+
- [Deploy your function app in isolation](security-concepts.md#deploy-your-function-app-in-isolation)
2121

2222
Access keys provide the basis for HTTP authorization in HTTP triggered functions. For more information, see [Authorization level](./functions-bindings-http-webhook-trigger.md#http-auth).
2323

@@ -30,9 +30,9 @@ The scope of an access key and the actions it supports depend on the type of acc
3030
| **Function** | `default` or user defined | `function` | Allows access only to a specific function endpoint. |
3131
| **Host** | `default` or user defined | `function` | Allows access to all function endpoints in a function app. |
3232
| **Master** | `_master` | `admin` | Special host key that also provides administrative access to the runtime REST APIs in a function app. Because the master key grants elevated permissions in your function app, you shouldn't share this key with third parties or distribute it in native client applications. |
33-
| **System** | Depends on the extension | n/a | Specific extensions might require a system-managed key to access webhook endpoints. System keys are designed for extension-specific function endpoints that get called by internal components. For example, the [Event Grid trigger](functions-bindings-event-grid-trigger.md) requires that the subscription use a system key when calling the trigger endpoint. Durable Functions also uses system keys to call [Durable Task extension APIs](durable/durable-functions-http-api.md). <br/>System keys can only be created by specific extensions, and you can't explicitly set their values. Like other keys, you can generate a new value for the key from the portal or by using the key APIs. |
33+
| **System** | Depends on the extension | n/a | Specific extensions might require a system-managed key to access webhook endpoints. System keys are designed for extension-specific function endpoints that get called by internal components. For example, the [Event Grid trigger](functions-bindings-event-grid-trigger.md) requires that the subscription use a system key when calling the trigger endpoint. Durable Functions also uses system keys to call [Durable Task extension APIs](durable/durable-functions-http-api.md). <br/>Only specific extensions can create system keys. You can't explicitly set their values. Like other keys, you can generate a new value for the key from the portal or by using the key APIs. |
3434

35-
Each key is named for reference, and there's a default key (named `default`) at the function and host level. Function keys take precedence over host keys. When two keys are defined with the same name, the function key is always used.
35+
Each key is named for reference. There's a default key (named `default`) at the function and host level. Function keys take precedence over host keys. When two keys are defined with the same name, the function key is always used.
3636

3737
The following table compares the uses for various kinds of access keys:
3838

@@ -48,9 +48,9 @@ The following table compares the uses for various kinds of access keys:
4848

4949
## Key requirements
5050

51-
In Functions, access keys are randomly generated 32-byte arrays that are encoded as URL-safe base-64 strings. While you can generate your own access keys and use them with Functions, we strongly recommend that you instead allow Functions to generate all of your access keys for you.
51+
In Functions, access keys are randomly generated 32-byte arrays that are encoded as URL-safe base-64 strings. While you can generate your own access keys and use them with Functions, we strongly recommend that you instead allow Functions to generate all of your access keys for you.
5252

53-
Functions-generated access keys include special signature and checksum values that indicate the type of access key and that it was generated by Azure Functions. Having these extra components in the key itself makes it much easier to determine the source of these kinds of secrets located during security scanning and other automated processes.
53+
Functions-generated access keys include special signature and checksum values that indicate the type of access key and that Azure Functions generated it. Having these extra components in the key itself makes it much easier to determine the source of these kinds of secrets located during security scanning and other automated processes.
5454

5555
To allow Functions to generate your keys for you, don't supply the key `value` to any of the APIs that you can use to generate keys.
5656

@@ -60,12 +60,12 @@ Keys are stored as part of your function app in Azure and are encrypted at rest.
6060

6161
|Location | Value | Description |
6262
|---------|---------|---------|
63-
| A second storage account | `blob` | Stores keys in Blob storage in a storage account that's different that the one used by the Functions runtime. The specific account and container used is defined by a shared access signature (SAS) URL set in the [`AzureWebJobsSecretStorageSas`](functions-app-settings.md#azurewebjobssecretstoragesas) setting. You must maintain the `AzureWebJobsSecretStorageSas` setting when the SAS URL changes. |
63+
| A second storage account | `blob` | Stores keys in Blob storage in a storage account that's different than the one used by the Functions runtime. The specific account and container used are defined by a shared access signature (SAS) URL set in the [`AzureWebJobsSecretStorageSas`](functions-app-settings.md#azurewebjobssecretstoragesas) setting. You must maintain the `AzureWebJobsSecretStorageSas` setting when the SAS URL changes. |
6464
| [Azure Key Vault](/azure/key-vault/general/overview) | `keyvault` | The key vault set in [`AzureWebJobsSecretStorageKeyVaultUri`](functions-app-settings.md#azurewebjobssecretstoragekeyvaulturi) is used to store keys. |
65-
| File system | `files` | Keys are persisted on the local file system, which is the default in Functions v1.x. File system storage isn't recommended. |
66-
| Kubernetes Secrets |`kubernetes` | The resource set in [AzureWebJobsKubernetesSecretName](functions-app-settings.md#azurewebjobskubernetessecretname) is used to store keys. Supported only when your function app is deployed to Kubernetes. The [Azure Functions Core Tools](functions-run-local.md) generates the values automatically when you use it to deploy your app to a Kubernetes cluster. [Immutable secrets](https://kubernetes.io/docs/concepts/configuration/secret/#secret-immutable) aren't supported |
65+
| File system | `files` | Keys are persisted on the local file system, which is the default in Functions v1.x. File system storage isn't recommended. |
66+
| Kubernetes Secrets |`kubernetes` | The resource set in [AzureWebJobsKubernetesSecretName](functions-app-settings.md#azurewebjobskubernetessecretname) is used to store keys. Supported only when your function app is deployed to Kubernetes. The [Azure Functions Core Tools](functions-run-local.md) generates the values automatically when you use it to deploy your app to a Kubernetes cluster. [Immutable secrets](https://kubernetes.io/docs/concepts/configuration/secret/#secret-immutable) aren't supported. |
6767

68-
When using Key Vault for key storage, the app settings you need depend on the managed identity type, either system-assigned or user-assigned.
68+
When you use Key Vault for key storage, the app settings you need depend on the managed identity type, either system-assigned or user-assigned.
6969

7070
| Setting name | System-assigned | User-assigned | App registration |
7171
| --- | --- | --- | --- |
@@ -78,18 +78,18 @@ When using Key Vault for key storage, the app settings you need depend on the ma
7878

7979
## Use access keys
8080

81-
HTTP triggered functions can generally be called by using a URL in the format: `https://<APP_NAME>.azurewebsites.net/api/<FUNCTION_NAME>`. When the authorization level of a given function is set a value other than `anonymous`, you must also provide an access key in your request. The access key can either be provided in the URL using the `?code=` query string or in the request header (`x-functions-key`). For more information, see [Access key authorization](functions-bindings-http-webhook-trigger.md#api-key-authorization).
81+
HTTP triggered functions can generally be called by using a URL that includes the function name. When the authorization level of a given function is set as a value other than `anonymous`, you must also provide an access key in your request. The access key can either be provided in the URL using the `?code=` query string or in the request header (`x-functions-key`). For more information, see [Access key authorization](functions-bindings-http-webhook-trigger.md#api-key-authorization).
8282

8383
To access the runtime REST APIs (under `/admin/`), you must provide the master key (`_master`) in the `x-functions-key` request header. You can [remove the admin endpoints](./security-concepts.md#disable-administrative-endpoints) using the `functionsRuntimeAdminIsolationEnabled` site property.
8484

8585
## Get your function access keys
8686

8787
You can get function and host keys programmatically by using these Azure Resource Manager APIs:
8888

89-
+ [List Function Keys](/rest/api/appservice/webapps/listfunctionkeys)
90-
+ [List Host Keys](/rest/api/appservice/webapps/listhostkeys)
91-
+ [List Function Keys Slot](/rest/api/appservice/webapps/listfunctionkeysslot)
92-
+ [List Host Keys Slot](/rest/api/appservice/webapps/listhostkeysslot).
89+
- [List Function Keys](/rest/api/appservice/webapps/listfunctionkeys)
90+
- [List Host Keys](/rest/api/appservice/webapps/listhostkeys)
91+
- [List Function Keys Slot](/rest/api/appservice/webapps/listfunctionkeysslot)
92+
- [List Host Keys Slot](/rest/api/appservice/webapps/listhostkeysslot)
9393

9494
To learn how to call Azure Resource Manager APIs, see the [Azure REST API reference](/rest/api/azure/).
9595

@@ -101,37 +101,37 @@ You can use these methods to get access keys without having to use the REST APIs
101101

102102
1. Select the function app you want to work with.
103103

104-
1. In the left pane, expand **Functions**, and then select **App keys**.
104+
1. In the left menu, expand **Functions**, and then select **App keys**.
105105

106106
The **App keys** page appears. On this page the host keys are displayed, which can be used to access any function in the app. The system key is also displayed, which gives anyone administrator-level access to all function app APIs.
107107

108108
You can also practice least privilege by using the key for a specific function. You can get function-specific keys from the **Function keys** tab of a specific HTTP-triggered function.
109109

110110
### [Azure CLI](#tab/azure-cli)
111111

112-
Run the following script in Azure Cloud Shell, the output of which is the `default` host key, which can be used to access any HTTP triggered function in the function app.
112+
Run the following command in Azure Cloud Shell. The output of the command is the `default` host key, which can be used to access any HTTP triggered function in the function app.
113113

114114
```azurecli-interactive
115115
az functionapp keys list --resource-group <RESOURCE_GROUP> --name <APP_NAME> --query functionKeys.default --output tsv
116116
```
117117

118-
In this script, replace `<RESOURCE_GROUP>` and `<APP_NAME>` with the resource group and your function app name, respective.
118+
Replace `<RESOURCE_GROUP>` and `<APP_NAME>` with the resource group and your function app name.
119119

120120
Because the output contains sensitive information, either don't persist the output or secure any persisted file outputs.
121121

122122
### [Azure PowerShell](#tab/azure-powershell)
123123

124-
Run the following script, the output of which is the `default` host key, which can be used to access any HTTP triggered function in the function app.
124+
Run the following script. The output is the `default` host key, which can be used to access any HTTP triggered function in the function app.
125125

126126
```powershell-interactive
127-
$subName = '<SUBSCRIPTION_ID>'
128127
$rGroup = '<RESOURCE_GROUP>'
129128
$appName = '<APP_NAME>'
130129
$path = "/subscriptions/$((Get-AzContext).Subscription.Id)/resourceGroups/$rGroup/providers/Microsoft.Web/sites/$appName/host/default/listKeys?api-version=2018-11-01"
130+
131131
((Invoke-AzRestMethod -Path $path -Method POST).Content | ConvertFrom-JSON).functionKeys.default
132132
```
133133

134-
In this script, replace `<RESOURCE_GROUP>` and `<APP_NAME>` with the resource group and your function app name, respective.
134+
In this script, replace `<RESOURCE_GROUP>` and `<APP_NAME>` with the resource group and your function app name.
135135

136136
---
137137

@@ -141,10 +141,10 @@ When you renew or create your access key values, you must manually redistribute
141141

142142
You can renew function and host keys programmatically or create new ones by using these Azure Resource Manager APIs:
143143

144-
+ [Create Or Update Function Secret](/rest/api/appservice/webapps/createorupdatefunctionsecret)
145-
+ [Create Or Update Function Secret Slot](/rest/api/appservice/webapps/createorupdatefunctionsecretslot)
146-
+ [Create Or Update Host Secret](/rest/api/appservice/webapps/createorupdatehostsecret)
147-
+ [Create Or Update Host Secret Slot](/rest/api/appservice/webapps/createorupdatehostsecretslot)
144+
- [Create Or Update Function Secret](/rest/api/appservice/webapps/createorupdatefunctionsecret)
145+
- [Create Or Update Function Secret Slot](/rest/api/appservice/webapps/createorupdatefunctionsecretslot)
146+
- [Create Or Update Host Secret](/rest/api/appservice/webapps/createorupdatehostsecret)
147+
- [Create Or Update Host Secret Slot](/rest/api/appservice/webapps/createorupdatehostsecretslot)
148148

149149
To learn how to call Azure Resource Manager APIs, see the [Azure REST API reference](/rest/api/azure/).
150150

@@ -156,7 +156,7 @@ You can use these methods to get access keys without having to manually create c
156156

157157
1. Select the function app you want to work with.
158158

159-
1. In the left pane, expand **Functions**, and then select **App keys**.
159+
1. In the left menu, expand **Functions**, and then select **App keys**.
160160

161161
The **App keys** page appears. On this page the host keys are displayed, which can be used to access any function in the app. The system key is also displayed, which gives anyone administrator-level access to all function app APIs.
162162

@@ -166,13 +166,13 @@ You can also renew a function key in the **Function keys** tab of a specific HTT
166166

167167
### [Azure CLI](#tab/azure-cli)
168168

169-
Run the following script in Azure Cloud Shell, which renews the `default` host key with a new key value generated by Functions.
169+
Run the following command in Azure Cloud Shell, which renews the `default` host key with a new key value generated by Functions.
170170

171171
```azurecli-interactive
172172
az functionapp keys set --resource-group <RESOURCE_GROUP> --name <APP_NAME> --key-type functionKeys --key-name default
173173
```
174174

175-
In this script, replace `<RESOURCE_GROUP>` and `<APP_NAME>` with the resource group and your function app name, respective. This script has been created to run in Azure Cloud Shell (Bash). You must modify it to run in a Windows terminal.
175+
In this command, replace `<RESOURCE_GROUP>` and `<APP_NAME>` with the resource group and your function app name. This command runs in Azure Cloud Shell (Bash). You must modify it to run in a Windows terminal.
176176

177177
The new key value generated by Functions is displayed for your reference. This new key value must be securely distributed to any apps that rely on the host key. Because the output contains sensitive information, either don't persist the output or secure any persisted file outputs.
178178

@@ -202,7 +202,7 @@ $response = Invoke-AzRestMethod -Method Post -Uri $uri -Payload $body
202202
($response.Content | ConvertFrom-Json).functionKeys.default
203203
```
204204

205-
In this script, replace `<RESOURCE_GROUP>` and `<APP_NAME>` with the resource group and your function app name, respective.
205+
In this script, replace `<RESOURCE_GROUP>` and `<APP_NAME>` with the resource group and your function app name.
206206

207207
The new key value generated by Functions is returned for your reference. It must be securely distributed to any apps that rely on the host key. Because the output contains sensitive information, either don't persist the output or secure any persisted file outputs.
208208

@@ -212,16 +212,16 @@ The new key value generated by Functions is returned for your reference. It must
212212

213213
You can delete function and host keys programmatically by using these Azure Resource Manager APIs:
214214

215-
+ [Delete Function Secret](/rest/api/appservice/webapps/deletefunctionsecret)
216-
+ [Delete Function Secret Slot](/rest/api/appservice/webapps/deletefunctionsecretslot)
217-
+ [Delete Host Secret](/rest/api/appservice/webapps/deletehostsecret)
218-
+ [Delete Host Secret Slot](/rest/api/appservice/webapps/deletehostsecretslot)
215+
- [Delete Function Secret](/rest/api/appservice/webapps/deletefunctionsecret)
216+
- [Delete Function Secret Slot](/rest/api/appservice/webapps/deletefunctionsecretslot)
217+
- [Delete Host Secret](/rest/api/appservice/webapps/deletehostsecret)
218+
- [Delete Host Secret Slot](/rest/api/appservice/webapps/deletehostsecretslot)
219219

220220
To learn how to call Azure Resource Manager APIs, see the [Azure REST API reference](/rest/api/azure/).
221221

222222
## Related content
223223

224-
+ [Securing Azure Functions](security-concepts.md)
225-
+ [Azure Functions HTTP trigger](functions-bindings-http-webhook-trigger.md)
226-
+ [Manage your function app](functions-how-to-use-azure-function-app-settings.md)
224+
- [Securing Azure Functions](security-concepts.md)
225+
- [Azure Functions HTTP trigger](functions-bindings-http-webhook-trigger.md)
226+
- [Manage your function app](functions-how-to-use-azure-function-app-settings.md)
227227

0 commit comments

Comments
 (0)