title | description | ms.topic | ms.date | ms.custom |
---|---|---|---|---|
How to configure Azure Functions with a virtual network |
Article that shows you how to perform certain virtual networking tasks for Azure Functions. |
conceptual |
03/04/2022 |
template-how-to |
This article shows you how to perform tasks related to configuring your function app to connect to and run on a virtual network. For an in-depth tutorial on how to secure your storage account, please refer to the Connect to a Virtual Network tutorial. To learn more about Azure Functions and networking, see Azure Functions networking options.
When you create a function app, you must create or link to a general-purpose Azure Storage account that supports Blob, Queue, and Table storage. You can replace this storage account with one that is secured with service endpoints or private endpoints. When configuring your storage account with private endpoints, public access to your storage account is not automatically disabled. In order to disable public access to your storage account, configure your storage firewall to allow access from only selected networks.
Note
This feature currently works for all Windows and Linux virtual network-supported SKUs in the Dedicated (App Service) plan and for Windows Elastic Premium plans. Consumption tier isn't supported.
To set up a function with a storage account restricted to a private network:
-
Create a function with a storage account that does not have service endpoints enabled.
-
Configure the function to connect to your virtual network.
-
Create or configure a different storage account. This will be the storage account we secure with service endpoints and connect our function.
-
Create a file share in the secured storage account.
-
Enable service endpoints or private endpoint for the storage account.
- If using private endpoint connections, the storage account will need a private endpoint for the
file
andblob
sub-resources. If using certain capabilities like Durable Functions, you will also needqueue
andtable
accessible through a private endpoint connection. - If using service endpoints, enable the subnet dedicated to your function apps for storage accounts.
- If using private endpoint connections, the storage account will need a private endpoint for the
-
Copy the file and blob content from the function app storage account to the secured storage account and file share.
-
Copy the connection string for this storage account.
-
Update the Application Settings under Configuration for the function app to the following:
Setting name Value Comment AzureWebJobsStorage
Storage connection string This is the connection string for a secured storage account. WEBSITE_CONTENTAZUREFILECONNECTIONSTRING
Storage connection string This is the connection string for a secured storage account. WEBSITE_CONTENTSHARE
File share The name of the file share created in the secured storage account where the project deployment files reside. WEBSITE_CONTENTOVERVNET
1 A value of 1 enables your function app to scale when you have your storage account restricted to a virtual network. You should enable this setting when restricting your storage account to a virtual network. -
Select Save to save the application settings. Changing app settings causes the app to restart.
After the function app restarts, it's now connected to a secured storage account.
[!div class="nextstepaction"] Azure Functions networking options