Unable to connect to any of the specified MySQL hosts. Once deployed, locally it works

Marc Jeeves 386 Reputation points
2023-01-20T01:08:52.3433333+00:00

Client->Function->Key Vault Secrets->Function->Database for MySQL->Function->Client

I'm using C# Visual Studio, i have created a function that gets secrets from the key vault for my SQL connection. I have created a database and table with some basic data.

When I run the application locally I can connect and retrieve the data either through chrome or postman.

Once i deploy the application i get the following message

Unable to connect to any of the specified MySQL hosts.

I know I'm missing a setting somewhere but I don't know where

thanks

Marc

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,112 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,248 questions
Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
712 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Marc Jeeves 386 Reputation points
    2023-01-20T03:44:58.1933333+00:00

    l don't have half those values, and my local.settings.json is default

    {
        "IsEncrypted": false,
        "Values": {
            "AzureWebJobsStorage": "UseDevelopmentStorage=true",
            "FUNCTIONS_WORKER_RUNTIME": "dotnet"
        }
    }
    

    User's image

    here are the two lines from my log, you can see it got the secrets and then failed to connect to the Db

    2023-01-20 02:54:49.935

    Number of Secrets Found is : 4

    Information

    2023-01-20 02:55:05.002

    Unable to connect to any of the specified MySQL hosts.

    Error

    0 comments No comments

  2. Marc Jeeves 386 Reputation points
    2023-01-20T04:01:02.1766667+00:00

    so i figured it out do i need to have both these on or is one or the other enough

    either or both allows it to work but which is safer

    thank

    Marc

    User's image

    0 comments No comments

  3. Marc Jeeves 386 Reputation points
    2023-01-20T04:08:07.8166667+00:00

    i ended up getting all of the outbound ips from the functions and adding them to the mysql firewall rules

    is this the correct approach

    User's image