Secure storage account linked to Function App with private endpoint

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.

Azure are offering to restrict the storage account to a virtual network. This feature currently works for all Windows virtual network-supported SKUs in the Dedicated (App Service) plan and for Windows Elastic Premium plans. It is also supported with private DNS for Linux virtual network-supported SKUs. Consumption and custom DNS for Linux plans aren't supported.

 

One can follow below steps to apply the configuration.

 

Prerequisite:

Function App:                   Need to be Elastic Premium plan to support Vnet integration

Storage Account:              Need to be StorageV2 (general purpose v2) or higher to support Private Endpoint

Vnet:                                 Needs to have two subnets, one is for function app, the other is for Private Endpoint for storage account

 

Detailed steps:

1. Create Function App on Elastic Premium plan, the binding storage account needs to be with pricing tier general purpose v2 or higher to support private endpoint. Both function app and storage account should be hosted in the same region for better performance.

If you created a lower pricing tier for storage account, you can go to portal through blade “Configuration” to change the pricing tier.

Function app:

Linru_Hui_0-1628847575142.png

 

Storage account:

Linru_Hui_2-1628847749919.png

 

2. Create Vnet and prepare two subnets. As mentioned previously, one is for function app, the other is used to enable Private Endpoint in storage account.

Linru_Hui_3-1628847796450.png

 

 

3. Integrate Vnet with your function app, select the subnet dedicated for your function.

Linru_Hui_4-1628847822438.png

 

 

 

Linru_Hui_5-1628847831131.png

 

 

4 Go to portal storage account, in blade Networking, select Tab “Private endpoints connections”.

4.1 Click on “+ Private endpoint”;

4.2 Input name for Private endpoint, then click Next: Resource

4.3 In the next page, choose storage account for “Resource type”, select the corresponding storage account, then select the target sub-source.  For function apps, you need to provide private endpoint for file and blob.  Click Next.

4.4 In configuration, select the vnet and subnet for private endpoints. Then review and create.

4.5 We need to create file and blob for function app, then go the whole scenario again to crate private endpoints for file. I myself created 4 private endpoints, blob, file, queue and table respectively.

Linru_Hui_6-1628847865427.png

 

 

 

Linru_Hui_7-1628847893834.png

Linru_Hui_9-1628847980161.png

 

 

Linru_Hui_8-1628847924667.png

 

 

5. Set up firewall in storage account, blade “Networking” , allow access from existing two subnets of Vnet.

Linru_Hui_10-1628848011535.png

 

6. Something need to be caution here, we need to add corresponding app settings WEBSITE_CONTENTOVERVNET, WEBSITE_DNS_SERVER, and WEBSITE_VNET_ROUTE_ALL  in order to make this feature work.

 

There is one thing you should be careful of when making these settings, as described in the feature documentation – the above settings should be set at the same time (in the same operation) as you set the WEBSITE_CONTENTAZUREFILECONNECTIONSTRING setting. This prevents some “confusion” on the Windows OS end when accessing the network share. Ordinarily, this would be set in a single ARM template, so all of the settings would naturally be set at the same time, but when experimenting in Portal, it’s easy to get the order wrong. Therefore, when enabling the feature on this site, you should first remove the Azure Files connection string (or point it somewhere else), wait a few minutes, then set the connection string at the same time as the other settings mentioned above.

 

Once done, it should be like this:

Linru_Hui_11-1628848059856.png

 

 

7. About runtime error reported in function portal – wake up the function runtime by accessing kudu site.

There is also sometimes a slight irregularity in how the feature interacts with Portal. It may report the “function runtime unreachable” error even when the feature itself is working as intended. Therefore, to verify whether the site is active, go to the SCM site’s Debug Console and verify that the content browser loads as usual. This “wakes up” the functions runtime and restores its connection to Portal.

 

Test with different deployment methods:

Storage account is secured with firewall. Private Endpoints also grant smooth deployment experience from both VSTS and Web Deployment.

Try deploy with Azure DevOps, it ended with success.

Linru_Hui_12-1628848131200.png

 

 

Try deploy from local PC (it is not using the same code base as we used in Azure DevOps, after deployment it should have 3 functions)

Linru_Hui_14-1628848376757.png

 

 

 

 

 

 

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.