azureazure-cognitive-services

Create Cognitive Search service indexer for MySQL data source: connectionString doesn't get saved


I'm creating an Azure Database for MySQL flexible server data source to use for a Cognitive Search service indexer using the 2020-06-30 preview API (following the guide from https://learn.microsoft.com/en-us/azure/search/search-howto-index-mysql) but my connectionString don't get saved. I'm using the ADO.NET connection string from the Azure portal MySQL server page when sending the create DS request. When I view the datasource on the portal or get it using the API with includeConnectionString=true it shows the connectionString as null.

Consequently, when I run the indexer using this data source, I get the following error message:

"Error with data source: Unable to connect to any of the specified MySQL hosts. Please adjust your data source definition in order to proceed."

POST request body:

{
    "name": "my-ds",
    "description": "desc",
    "type": "mysql",
    "credentials": {
        "connectionString": "Server='mysql-shared.mysql.database.azure.com';UserID = 'admin';Password='admin';Database='mydb';SslMode=Preferred;"
    },
    "container": {
        "name": "posts"
    },
    "dataChangeDetectionPolicy": {
        "@odata.type": "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy",
        "highWaterMarkColumnName": "post_modified"
    }
}

I've also tried this version of the connection string:

"Server=mysql-shared.MySQL.database.azure.com; Port=3306; Database=mydb; Uid=admin; Pwd=admin; SslMode=Preferred;"

PS: I haven't signed up for the indexer preview, is this mandatory? On the guide it says sign up "to provide feedback and get help with any issues you encounter" so I assumed it wasn't required. And I am able to use the API for everything except for the connection string part. Either way I've signed up now but I'm not sure how long it'll take to be approved.


Solution

  • Turns out it wasn't actually null but it was just being displayed that way. The reason for my "Unable to connect" error was due to some firewall issues when connecting from my search service to my SQL. Turning on the "Allow public access from any Azure service within Azure to this server" setting for the MySQL server fixed it. Still weird that it showed null even with includeConnectionString=true though.