Unable to connect via Web App to Azure Database for MySQL flexible server

Uhmazing34 30 Reputation points
2023-06-13T10:23:42.82+00:00

Hello,

I have recently created two different Azure Databases for MySQL flexible server.
I already had 2 active Azure App Services (Web Apps) in use, so I configured it in a way that the Azure Database for MySQL can only be connected via the Azure Web App (private link / VNet integration).

The private connection between one Web App - Azure Database is working correctly, however, the second connection between the other Web App and Database is not working. Connecting via MySQL Workbench does work, just connecting from the Web App does not work.

Could anyone perhaps tell me what I'm doing wrong?

  • The Web App (App Service) was already in place, I did not change anything there.
    • When creating the Azure Database for MySQL Flexible Server, I did the following:
    • Placed in the same Resource Group as the App Service
    • Chose Private access (VNet Integration)
    • Selected the same subnet as where the other Azure Database for MySQL is in (This subnet is delegated for use only with MySQL Flexible Server (Microsoft.DBforMySQL/flexibleServers)
    • Created a new Private DNS zone
  • Went to the App Service -> Networking -> VNet integration -> Created a new subnet
  • Went to Private DNS zones -> Settings -> Virtual network links -> Made sure that the Private DNS zone was linked with the VNet, which was the case.

Those are the steps that I executed. Did I do something wrong or is there something missing?

Thank you in advance..

Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
986 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Sedat SALMAN 14,180 Reputation points MVP
    2023-06-13T22:15:25.8833333+00:00

    Make sure the NSG associated with the subnet where your MySQL Flexible Server is located allows outbound traffic to your MySQL Flexible Server.

    Check if the private endpoint connection from your Web App to the MySQL Flexible Server is approved and in a connected state.

    Double-check the connection string used in your Web App. Ensure it's pointing to the correct MySQL Flexible Server and the credentials are correct.

    Ensure that the MySQL Flexible Server firewall is configured to allow connections from the Web App.

    The issue could be related to DNS resolution. Since you're using private link and DNS, make sure that the DNS name of the MySQL server is resolvable from the Web App.

    0 comments No comments

  2. brtrach-MSFT 17,731 Reputation points Microsoft Employee Moderator
    2023-06-14T02:48:36.2466667+00:00

    It seems like you have followed the correct steps to connect your Azure Web App to the Azure Database for MySQL flexible server. However, there could be a few reasons why the connection is not working.

    Have you checked if the firewall rules are configured correctly? Check this by going to the Azure Database for MySQL flexible server and checking the firewall rules. Make sure that the IP address of the Azure Web App is added to the firewall rules.

    Next item is have you checked if the connection string is correct? (You mentioned a lot about doing the ride things at the network layer but have you ensured you've added your connection string?) You can locate this by going to the Azure Web App and checking the connection string. Make sure that the connection string is pointing to the correct Azure Database for MySQL flexible server.

    1. Go to the Azure Portal and navigate to your Azure Web App.
    2. Click on the "Configuration" tab in the left-hand menu.
    3. Scroll down to the "Connection strings" section.
    4. You should see a list of connection strings. Look for the connection string that is used to connect to your Azure Database for MySQL flexible server.
    5. If you click on the connection string, you should be able to see the details of the connection string, including the server name, username, and password.

    If the firewall rules and connection string are correct, then there could be an issue with the VNet peering. You can check this by going to the Azure Portal and checking the VNet peering between the two VNets. Make sure that the VNet peering is established correctly.

    If you have checked all of the above, then there could be an issue with the Private DNS zone. Check this by going to the Private DNS zone and checking if the DNS records are correct. Make sure that the DNS records are pointing to the correct IP address of the Azure Database for MySQL flexible server.

    0 comments No comments

  3. Uhmazing34 30 Reputation points
    2023-06-22T12:24:02+00:00

    Thank you for your replies @Sedat SALMAN and @brtrach-MSFT

    How do I check the firewall rules of my Azure Database for MySQL flexible server?
    Under "Settings -> Networking" I do not have the option to whitelist IP addresses because I chose the connectivity method "Private access (VNet Integration)":

    User's image

    Regarding the connection string, I have not added a connection string. I guess this is what is causing the issue?
    When adding a new connection string, what would I have to fill in in the fields below?
    User's image

    Thank you in advance.

    0 comments No comments

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.