I am trying to access SQL Server hosted in Azure VM from Azure function app

Ritika Pandey 25 Reputation points
2024-07-04T13:03:53.9366667+00:00

I am trying to access SQL Server hosted in Azure VM from Azure function app, but getting connection timeout error while connecting through it.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,478 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,210 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Nikhil Duserla 645 Reputation points Microsoft Vendor
    2024-07-04T15:39:45.8166667+00:00

    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 the host.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."