How to secure access to host storage account for Function Apps on Windows Elastic Premium Plan with VNET Integration

ZQadir 195 Reputation points
2023-01-20T11:15:47.8066667+00:00

Background / Setup:

  • Function Apps on Windows Elastic Premium Plan (EP1) with Zone Redundancy and Auto Scaling from 3 to x nodes.
  • Inbound access control on main site and advanced tool site of the Function App. Deny all for advanced tool site with temporary whitelisting of deployment agent IP for any new deployments.
  • VNET Integration for outbound access control. Respective service endpoints enabled on the subnet used for VNET Integration. Target resources (business data storage accounts, key vault, SQL servers, service bus etc.) have Network ACLS to allow access for the subnet used for VNET integration by Function Apps. Target resources do have IAM/RBAC using the System Assigned Managed Identity of relevant Function Apps. Access to such target resource is working with Service Endpoints and Managed Identity using the latest extensions in Function Apps.
  • Functions are coded in C# using .NET 6, and deployed using Azure DevOps Pipelines.
  • Function Apps have FUNCTIONS_EXTENSION_VERSION = ~4, FUNCTIONS_WORKER_RUNTIME = dotnet, WEBSITE_CONTENTOVERVNET = 1  and vnetRouteAllEnabled
  • Separate host storage accounts for each of the function apps, configured as Standard, General Purpose V2 with Zone Redundant Storage

Question:

How can we best secure access to the host storage account used by each of the Function App on Windows Elastic Premium Plan that uses VNET Integration?

Our preferred solution for this will be:

  • IAM/RBAC on the host storage account using system assigned managed identity of the function app, so that we don’t have to worry about rotating storage account keys.
  • Implement Network ACLs on host storage account so that only the subnet that’s used for VNET integration by Windows Elastic Premium Plan and Function apps are allowed access to it, using the Service Endpoints.

 Hurdles in our preferred solution:

  • We have tried implementing managed identity based access for host storage account instead of the typical storage account key based approach. However, the managed identity based access isn’t supported for the WEBSITE_CONTENTAZUREFILECONNECTIONSTRING setting, which is needed for Windows Elastic Premium Plan. So, we have to use storage account key based access for this setting. Moreover, managed identity based access is still in preview. So, we parked that and for now and ended up in using Account Key based access to host storage accounts of Function Apps for both AzureWebJobsStorage and CONTENTAZUREFILECONNECTIONSTRING. References: https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference?tabs=blob#connecting-to-host-storage-with-an-identity-preview and How to use managed identity for WEBSITE_CONTENTAZUREFILECONNECTIONSTRING · Issue #86604 · MicrosoftDocs/azure-docs · GitHub
  • We have tried implementing the Network ACLs on the host storage account; by provisioning the storage account with Network ACLs upfront, and then using storage account when provisioning the Function Apps that has VNET integration to the subnet that’s whitelisted on the storage account, and has service endpoints enabled. We made the function app to functionally work. However, we noticed a few Failures reported in the dashboard when we go to the Insights of that host storage account in Azure Portal. Expanding those failures, show errors related to File service with various error codes. Looking at the Microsoft documentation for implementing Network ACLs on host storage account with service endpoints based access for Function Apps here, https://learn.microsoft.com/en-us/azure/azure-functions/configure-networking-how-to#restrict-your-storage-account-to-a-virtual-network,  we noticed that it follows a two step process i.e., provision a function app with a storage account that has not got the Network ACLs and no Service Endpoints based access, and later replace it with another storage account that has Network ACLs and Service Endpoints based access. Not sure what’s the reason for that two step approach as compared to the one step approach that we follow, and if the errors on the host storage account are due to this deviation from Microsoft outlined 2 step approach.   

Concluding remark:

Keeping the above setup in view, what’s the best officially supported way to secure access to the host storage accounts for the Function Apps (even if that way is different than our preferred solution) running on Window Elastic Premium Plan with VNET Integration?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
{count} votes

Answer accepted by question author
  1. MughundhanRaveendran-MSFT 12,511 Reputation points
    2023-02-04T11:05:26.06+00:00

    @ZQadir

    Thanks for the detailed explanation and insights.

    "IAM/RBAC on the host storage account using system assigned managed identity of the function app, so that we don’t have to worry about rotating storage account keys".

    • This would be the ideal approach however as you mentioned, the feature is still in preview and you will have to wait for it to become GA. Until that time, you can continue to use the storage account keys

    "Implement Network ACLs on host storage account so that only the subnet that’s used for VNET integration by Windows Elastic Premium Plan and Function apps are allowed access to it, using the Service Endpoints".

    • This is also the recommended approach, there is no need to create two storage account. The first storage account that was created can be used to implement ACL. Could you please let me know what is the error that you see in the File service? Please provide screenshot.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.