Hi Ritika Pandey,
Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.
We understand from your query that you are experiencing an issue trying to access SQL Server hosted in Azure VM from Azure function app.
Please follow these troubleshooting steps that will help to resolve the issue:
Network Connectivity Issues:
- VNet Integration: Ensure that your Azure Function App is configured to use VNet integration, and the VNet is the same as the one used by the Azure VM hosting the SQL Server.
- Subnet and NSG Configuration: Verify that the subnet and network security group (NSG) rules allow incoming traffic on the SQL Server port (1433 by default) from the Function App's IP address.
- Private IP Address: Double-check that you're using the private IP address of the Azure VM hosting the SQL Server in your connection string.
Function App Configuration:
- Function App Timeout: Check the Function App's timeout settings. If the timeout is set too low, it may cause connection timeouts. You can increase the timeout by updating the
functionTimeout
setting in thehost.json
file.
Ensure that the SQL Server firewall rules allow incoming connections from the Function App's IP address.
We will also recommend reading these Timeout expired messages when connecting to SQL Server.
If you have any further queries, do let us know.
If the answer is helpful, please click "Accept Answer" and "Upvote it."