|
1 | 1 | ---
|
2 | 2 | title: How to use a secured storage account with Azure Functions
|
3 |
| -description: Article that shows you how to use a secured storage account in a virtual network as the default storage account for a function app in Azure Functions. |
| 3 | +description: Learn how to use a secured storage account in a virtual network as the default storage account for a function app in Azure Functions. |
| 4 | +ms-service: azure-functions |
4 | 5 | ms.topic: how-to
|
5 |
| -ms.date: 06/03/2024 |
| 6 | +ms.date: 06/27/2024 |
6 | 7 | ms.custom: template-how-to, build-2024
|
| 8 | + |
| 9 | +# Customer intent: As a developer, I want to understand how to use a secured storage account in a virtual network as the default storage account for my function app, so that my function app can be secure. |
| 10 | + |
7 | 11 | ---
|
8 | 12 |
|
9 | 13 | # How to use a secured storage account with Azure Functions
|
10 | 14 |
|
11 |
| -This article shows you how to connect your function app to a secured storage account. For an in-depth tutorial on how to create your function app with inbound and outbound access restrictions, refer to the [Integrate with a virtual network](functions-create-vnet.md) tutorial. To learn more about Azure Functions and networking, see [Azure Functions networking options](functions-networking-options.md). |
| 15 | +This article shows you how to connect your function app to a secured storage account. For an in-depth tutorial on how to create your function app with inbound and outbound access restrictions, see the [Integrate with a virtual network](functions-create-vnet.md) tutorial. To learn more about Azure Functions and networking, see [Azure Functions networking options](functions-networking-options.md). |
12 | 16 |
|
13 |
| -## Restrict your storage account to a virtual network |
| 17 | +## Restrict your storage account to a virtual network |
14 | 18 |
|
15 |
| -When you create a function app, you either create a new storage account or link to an existing one. Currently, only the Azure portal, [ARM template deployments](functions-infrastructure-as-code.md?tabs=json&pivots=premium-plan#secured-deployments), and [Bicep deployments](functions-infrastructure-as-code.md?tabs=bicep&pivots=premium-plan#secured-deployments) support function app creation with an existing secured storage account. |
| 19 | +When you create a function app, you either create a new storage account or link to an existing one. Currently, only the Azure portal, [ARM template deployments](functions-infrastructure-as-code.md?tabs=json&pivots=premium-plan#secured-deployments), and [Bicep deployments](functions-infrastructure-as-code.md?tabs=bicep&pivots=premium-plan#secured-deployments) support function app creation with an existing secured storage account. |
16 | 20 |
|
17 | 21 | > [!NOTE]
|
18 |
| -> Securing your storage account is supported for all tiers of the [Dedicated (App Service) plan](./dedicated-plan.md) and the [Elastic Premium plan](./functions-premium-plan.md), as well as in the [Flex Consumption plan](./flex-consumption-plan.md). |
| 22 | +> Secured storage accounts are supported for all tiers of the [Dedicated (App Service) plan](./dedicated-plan.md) and the [Elastic Premium plan](./functions-premium-plan.md). They're also supported by the [Flex Consumption plan](./flex-consumption-plan.md). |
19 | 23 | > The [Consumption plan](consumption-plan.md) doesn't support virtual networks.
|
20 | 24 |
|
21 | 25 | For a list of all restrictions on storage accounts, see [Storage account requirements](storage-considerations.md#storage-account-requirements).
|
22 | 26 |
|
23 | 27 | [!INCLUDE [functions-flex-preview-note](../../includes/functions-flex-preview-note.md)]
|
24 | 28 |
|
25 |
| -## Secure storage during function app creation |
| 29 | +## Secure storage during function app creation |
26 | 30 |
|
27 |
| -You can create a function app along with a new storage account that is secured behind a virtual network. The following links show you how to create these resources by using either the Azure portal or by using deployment templates: |
| 31 | +You can create a function app, along with a new storage account that is secured behind a virtual network. The following sections show you how to create these resources by using either the Azure portal or by using deployment templates. |
28 | 32 |
|
29 | 33 | ### [Azure portal](#tab/portal)
|
30 | 34 |
|
31 | 35 | Complete the steps in [Create a function app in a Premium plan](functions-create-vnet.md#create-a-function-app-in-a-premium-plan). This section of the virtual networking tutorial shows you how to create a function app that connects to storage over private endpoints.
|
32 | 36 |
|
33 |
| -> [!NOTE] |
| 37 | +> [!NOTE] |
34 | 38 | > When you create your function app in the Azure portal, you can also choose an existing secured storage account in the **Storage** tab. However, you must configure the appropriate networking on the function app so that it can connect through the virtual network used to secure the storage account. If you don't have permissions to configure networking or you haven't fully prepared your network, select **Configure networking after creation** in the **Networking** tab. You can configure networking for your new function app in the portal under **Settings** > **Networking**.
|
35 | 39 |
|
36 | 40 | ### [Deployment templates](#tab/templates)
|
37 | 41 |
|
38 |
| -Use Bicep files or Azure Resource Manager (ARM) templates to create a secured function app and storage account resources. When you create a secured storage account in an automated deployment, you must set the `vnetContentShareEnabled` site property, create the file share as part of your deployment, and set the `WEBSITE_CONTENTSHARE` app setting to the name of the file share. For more information, including links to example deployments, see [Secured deployments](functions-infrastructure-as-code.md#secured-deployments). |
| 42 | +Use Bicep files or Azure Resource Manager (ARM) templates to create a secured function app and storage account resources. When you create a secured storage account in an automated deployment, you must set the `vnetContentShareEnabled` site property, create the file share as part of your deployment, and set the `WEBSITE_CONTENTSHARE` app setting to the name of the file share. For more information, including links to example deployments, see [Secured deployments](functions-infrastructure-as-code.md?pivots=premium-plan#secured-deployments). |
39 | 43 |
|
40 | 44 | ---
|
41 | 45 |
|
42 | 46 | ## Secure storage for an existing function app
|
43 | 47 |
|
44 |
| -When you have an existing function app, you can directly configure networking on the storage account being used by the app. This process results in your app being down while you configure networking and while your app restarts. |
| 48 | +When you have an existing function app, you can directly configure networking on the storage account being used by the app. However, this process results in your function app being down while you configure networking and while your function app restarts. |
45 | 49 |
|
46 | 50 | To minimize downtime, you can instead swap-out an existing storage account for a new, secured storage account.
|
47 | 51 |
|
48 | 52 | ### 1. Enable virtual network integration
|
49 | 53 |
|
50 |
| -As a prerequisite, you need to enable virtual network integration for your function app. |
| 54 | +As a prerequisite, you need to enable virtual network integration for your function app: |
51 | 55 |
|
52 | 56 | 1. Choose a function app with a storage account that doesn't have service endpoints or private endpoints enabled.
|
53 | 57 |
|
54 | 58 | 1. [Enable virtual network integration](./functions-networking-options.md#enable-virtual-network-integration) for your function app.
|
55 | 59 |
|
56 |
| -### 2. Create a secured storage account |
| 60 | +### 2. Create a secured storage account |
57 | 61 |
|
58 |
| -Set up a secured storage account for your function app: |
| 62 | +Set up a secured storage account for your function app: |
59 | 63 |
|
60 |
| -1. [Create a second storage account](../storage/common/storage-account-create.md). This is going to be the secured storage account that your function app will use instead. You can also use an existing storage account not already being used by Functions. |
| 64 | +1. [Create a second storage account](../storage/common/storage-account-create.md). This storage account is the secured storage account for your function app to use instead of its original unsecured storage account. You can also use an existing storage account not already being used by Functions. |
61 | 65 |
|
62 |
| -1. Copy the connection string for this storage account. You need this string for later. |
| 66 | +1. Save the connection string for this storage account to use later. |
63 | 67 |
|
64 |
| -1. [Create a file share](../storage/files/storage-how-to-create-file-share.md#create-a-file-share) in the new storage account. Try to use the same name as the file share in the existing storage account. Otherwise, you'll need to copy the name of the new file share to configure an app setting later. |
| 68 | +1. [Create a file share](../storage/files/storage-how-to-create-file-share.md#create-a-file-share) in the new storage account. For your convenience, you can use the same file share name from your original storage account. Otherwise, if you use a new file share name, you must update your app setting. |
65 | 69 |
|
66 | 70 | 1. Secure the new storage account in one of the following ways:
|
67 | 71 |
|
68 |
| - * [Create a private endpoint](../storage/common/storage-private-endpoints.md#creating-a-private-endpoint). When you set up private endpoint connections, create private endpoints for the `file` and `blob` subresources. For Durable Functions, you must also make `queue` and `table` subresources accessible through private endpoints. If you're using a custom or on-premises DNS server, make sure you [configure your DNS server](../storage/common/storage-private-endpoints.md#dns-changes-for-private-endpoints) to resolve to the new private endpoints. |
| 72 | + * [Create a private endpoint](../storage/common/storage-private-endpoints.md#creating-a-private-endpoint). As you set up your private endpoint connection, create private endpoints for the `file` and `blob` subresources. For Durable Functions, you must also make `queue` and `table` subresources accessible through private endpoints. If you're using a custom or on-premises Domain Name System (DNS) server, [configure your DNS server](../storage/common/storage-private-endpoints.md#dns-changes-for-private-endpoints) to resolve to the new private endpoints. |
69 | 73 |
|
70 |
| - * [Restrict traffic to specific subnets](../storage/common/storage-network-security.md#grant-access-from-a-virtual-network). Ensure that one of the allowed subnets is the one your function app is network integrated with. Double check that the subnet has a service endpoint to Microsoft.Storage. |
| 74 | + * [Restrict traffic to specific subnets](../storage/common/storage-network-security.md#grant-access-from-a-virtual-network). Ensure your function app is network integrated with an allowed subnet and that the subnet has a service endpoint to `Microsoft.Storage`. |
71 | 75 |
|
72 |
| -1. Copy the file and blob content from the current storage account used by the function app to the newly secured storage account and file share. [AzCopy](../storage/common/storage-use-azcopy-blobs-copy.md) and [Azure Storage Explorer](https://techcommunity.microsoft.com/t5/azure-developer-community-blog/azure-tips-and-tricks-how-to-move-azure-storage-blobs-between/ba-p/3545304) are common methods. If you use Azure Storage Explorer, you may need to allow your client IP address into your storage account's firewall. |
| 76 | +1. Copy the file and blob content from the current storage account used by the function app to the newly secured storage account and file share. [AzCopy](../storage/common/storage-use-azcopy-blobs-copy.md) and [Azure Storage Explorer](https://techcommunity.microsoft.com/t5/azure-developer-community-blog/azure-tips-and-tricks-how-to-move-azure-storage-blobs-between/ba-p/3545304) are common methods. If you use Azure Storage Explorer, you might need to allow your client IP address access to your storage account's firewall. |
73 | 77 |
|
74 | 78 | Now you're ready to configure your function app to communicate with the newly secured storage account.
|
75 | 79 |
|
76 | 80 | ### 3. Enable application and configuration routing
|
77 | 81 |
|
78 | 82 | > [!NOTE]
|
79 |
| -> These configuration steps are only required for the [Elastic Premium](./functions-premium-plan.md) and [Dedicated (App Service)](./dedicated-plan.md) hosting plans. |
| 83 | +> These configuration steps are required only for the [Elastic Premium](./functions-premium-plan.md) and [Dedicated (App Service)](./dedicated-plan.md) hosting plans. |
80 | 84 | > The [Flex Consumption plan](./flex-consumption-plan.md) doesn't require site settings to configure networking.
|
81 | 85 |
|
82 |
| -You should now route your function app's traffic to go through the virtual network. |
| 86 | +You're now ready to route your function app's traffic to go through the virtual network: |
83 | 87 |
|
84 |
| -1. Enable [application routing](../app-service/overview-vnet-integration.md#application-routing) to route your app's traffic into the virtual network. |
| 88 | +1. Enable [application routing](../app-service/overview-vnet-integration.md#application-routing) to route your app's traffic to the virtual network: |
85 | 89 |
|
86 |
| - * Navigate to the **Networking** tab of your function app. Under **Outbound traffic configuration**, select the subnet associated with your virtual network integration. |
| 90 | + 1. In your function app, expand **Settings**, and then select **Networking**. In the **Networking** page, under **Outbound traffic configuration**, select the subnet associated with your virtual network integration. |
87 | 91 |
|
88 |
| - * In the new page, check the box for **Outbound internet traffic** under **Application routing**. |
| 92 | + 1. In the new page, under **Application routing**, select **Outbound internet traffic**. |
89 | 93 |
|
90 |
| -1. Enable [content share routing](../app-service/overview-vnet-integration.md#content-share) to have your function app communicate with your new storage account through its virtual network. |
91 |
| - |
92 |
| - * In the same page, check the box for **Content storage** under **Configuration routing**. |
| 94 | +1. Enable [content share routing](../app-service/overview-vnet-integration.md#content-share) to enable your function app to communicate with your new storage account through its virtual network. In the same page as the previous step, under **Configuration routing**, select **Content storage**. |
93 | 95 |
|
94 | 96 | ### 4. Update application settings
|
95 | 97 |
|
96 |
| -Finally, you need to update your application settings to point at the new secure storage account. |
| 98 | +Finally, you need to update your application settings to point to the new secure storage account: |
97 | 99 |
|
98 |
| -1. Update the **Application Settings** under the **Configuration** tab of your function app to the following: |
| 100 | +1. In your function app, expand **Settings**, and then select **Environment variables**. |
| 101 | +1. In the **App settings** tab, update the following settings by selecting each setting, editing it, and then selecting **Apply**: |
99 | 102 |
|
100 | 103 | | Setting name | Value | Comment |
|
101 | 104 | |----|----|----|
|
102 |
| - | [`AzureWebJobsStorage`](./functions-app-settings.md#azurewebjobsstorage)<br>[`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`](./functions-app-settings.md#website_contentazurefileconnectionstring) | Storage connection string | Both settings contain the connection string for the new secured storage account, which you saved earlier. | |
103 |
| - | [`WEBSITE_CONTENTSHARE`](./functions-app-settings.md#website_contentshare) | File share | The name of the file share created in the secured storage account where the project deployment files reside. | |
| 105 | + | [`AzureWebJobsStorage`](./functions-app-settings.md#azurewebjobsstorage)| Storage connection string | Use the connection string for your new secured storage account, which you saved earlier. | |
| 106 | + | [`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`](./functions-app-settings.md#website_contentazurefileconnectionstring) | Storage connection string | Use the connection string for your new secured storage account, which you saved earlier. | |
| 107 | + | [`WEBSITE_CONTENTSHARE`](./functions-app-settings.md#website_contentshare) | File share | Use the name of the file share created in the secured storage account where the project deployment files reside. | |
| 108 | + |
| 109 | +1. Select **Apply**, and then **Confirm** to save the new application settings in the function app. |
104 | 110 |
|
105 |
| -1. Select **Save** to save the application settings. Changing app settings causes the app to restart. |
| 111 | + The function app restarts. |
106 | 112 |
|
107 |
| -After the function app restarts, it's now connected to a secured storage account. |
| 113 | +After the function app finishes restarting, it connects to the secured storage account. |
108 | 114 |
|
109 | 115 | ## Next steps
|
110 | 116 |
|
|
0 commit comments