Restrict Azure function to access storage account and Key vault

Nandhini Balasubramanian 20 Reputation points
2024-08-30T02:19:32.95+00:00

I have a Azure functions that sends SMS's and redirects call using Twilio messaging service. It does not use any Storage account, uses only Azure key vault. How to restrict public access to a storage account and allow only the Azure functions to access it. Also impose the same restrictions to Azure key vaults as well. These app are on Consumption plan. Kindly advice.

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,257 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,890 questions
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,105 questions
Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,401 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vinodh247 18,101 Reputation points
    2024-08-30T05:21:25.12+00:00

    Hi Nandhini Balasubramanian,

    Thanks for reaching out to Microsoft Q&A.

    Since your Azure Function is on a consumption plan and doesn’t directly use the storage account, lets try on how to restrict public access:

    Restrict Public Access to Storage Account

    • Disable Public Access on Storage Account
    • Use Managed Identity for Azure Functions
      • Assign MI to Azure Function
      • Assign Storage Account Role to MI

    Restrict Public Access to Azure KV

    Use Virtual Network Service Endpoints or Private Endpoint

    • Since your function app is on the Consumption plan, you can't use VNet integration, but you can still restrict access
    • Use MI for Azure Functions:

    Ensure Azure Function Can Still Access Resources

    • After restricting public access, your Azure Function (through its mi) will be able to access the storage account and KV securely. This configuration prevents unauthorized access and secures your resources.

    Note:

    • Make sure that your MI has the correct roles assigned both for the Storage account and the KV.

    The above steps will help you to make sure that only your Azure Function can access the storage account and KV, while blocking public access.

    Please 'Upvote'(Thumbs-up) and 'Accept' as an answer if the reply was helpful. This will benefit other community members who face the same issue.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Nandhini Balasubramanian 20 Reputation points
    2024-09-02T00:12:11.4266667+00:00

    Hi @Vinodh247 ,

    Thanks for your response.

    I am not able to set MI to Azure Function as it is being used as a webhoook in Twilio console. It uses Twilio API key and X-Twilio-Signature HTTP header to do a two-factor authentication. Can we use the system assigned MI instead?

    Is there an alternate solution that would enable me to ensure only my Azure Functions can access the storage account and KV, while blocking public access.

    Thanks


Your answer

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