Securing function apps
A function app holds connection strings, keys and data, and HTTP functions are open to the internet. Secure it with managed identities instead of secrets, proper authentication, and network controls.
- CallersEntra ID tokens for users, keys only for services.
- GatewayAPI Management, CORS and rate limits.
- Function appManaged identity, HTTPS only, TLS 1.2, no FTP.
- ResourcesRole-based access over private endpoints.
Remove secrets first, then close the network.
Managed identity instead of connection strings
Give the function app a managed identity, grant it a role on each resource, and configure the binding connection with a service URI instead of a secret. The same names work for triggers and SDK clients.
{
"Storage__queueServiceUri": "https://shopstore.queue.core.windows.net",
"Storage__blobServiceUri": "https://shopstore.blob.core.windows.net",
"ServiceBus__fullyQualifiedNamespace": "shop-bus.servicebus.windows.net",
"AzureWebJobsStorage__accountName": "shopfuncstore"
}Grant only the roles needed
az role assignment create --assignee <principal-id> \
--role "Storage Queue Data Message Processor" \
--scope /subscriptions/<sub>/resourceGroups/rg-shop/providers/Microsoft.Storage/storageAccounts/shopstore
az role assignment create --assignee <principal-id> \
--role "Azure Service Bus Data Receiver" \
--scope /subscriptions/<sub>/resourceGroups/rg-shop/providers/Microsoft.ServiceBus/namespaces/shop-busWho can call your HTTP functions
- Function and admin keys are shared secrets. Rotate them, keep them out of front-end code, and use them only for webhooks and service-to-service calls.
- For users, turn on App Service authentication with Microsoft Entra ID (or another provider) and check roles or claims in code.
- Put Azure API Management in front for rate limits, subscriptions and a single public gateway.
- Set CORS to your real front-end origins only; never use * for an API that uses cookies or keys.
Platform settings
- HTTPS only, minimum TLS 1.2, and FTP disabled.
- Use private endpoints and VNet integration so storage and databases are not reachable from the internet.
- Store remaining secrets in Key Vault and use Key Vault references in app settings.
- Keep packages and the .NET version current; move off the in-process model, whose support ends on 10 November 2026.
Interview question
How do you connect an Azure Function to Service Bus without a connection string?
I enable a managed identity on the function app and give it the Azure Service Bus Data Receiver role on the namespace or queue. Then I set an app setting such as ServiceBus__fullyQualifiedNamespace to the namespace host name and use Connection = "ServiceBus" on the trigger. No secret is stored, and access can be removed by deleting the role assignment.
Want the full details? Read the official Microsoft documentation for this topic.