question

CloudRock avatar image
0 Votes"
CloudRock asked JacoduToit-1075 answered

How to run azure runbook against azure database for mysql ?

Hello

I need to run an azure runbook from azure automation account against an azure database for mysql.

I enabled "Run as an Account" option and added SQL Server module at automation account. I created credentials for azure database for mysql.

The SQL script is located in an Azure File Share folder.

The runbook script looks like this


 $AzureSQLServerName = "XXXXXX.mysql.database.azure.com"
 $AzureSQLDatabaseName = "XXXXXXX"
 $AzureSQLInputFilePath = "https://XXXXX.file.core.windows.net/XXXXXXXXXX/XXXXXXXXXXXXXXXX.sql"
    
 $Cred = Get-AutomationPSCredential -Name "XXXXXXXXX"
    
 $SQLOutput = $(Invoke-Sqlcmd -ServerInstance $AzureSQLServerName -Username $Cred.UserName -Password $Cred.GetNetworkCredential().Password -Database $AzureSQLDatabaseName -InputFile $AzureSQLInputFilePath) 4>&1
    
 Write-Output $SQLOutput

But I receive this error message :

 Invoke-Sqlcmd : The given path's format is not supported. At line:7 char:16 + ... LOutput = $(Invoke-Sqlcmd -ServerInstance $AzureSQLServerName -Userna ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidResult: (............mysql.database.azure.com:PSObject) [Invoke-Sqlcmd], NotSupportedException + FullyQualifiedErrorId : ExecutionFailed,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand


It seems request is valid for azure sql server but not for azure database for mysql.

windows-server-powershellazure-automationazure-database-mysql
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SwathiDhanwada-MSFT avatar image
1 Vote"
SwathiDhanwada-MSFT answered CloudRock commented

@CloudRock Kindly note Invoke-sqlcmd only works for Azure Sql Server. Data plane operations are not possible with mysql since it is not a first party MS product. Only for Azure SQL we can do both management and data plane operations.

For your reference, list of PowerShell commands available for Azure Database for Mysql can be checked from here.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for your answer.

0 Votes 0 ·
JacoduToit-1075 avatar image
0 Votes"
JacoduToit-1075 answered

I have managed to get a runbook connecting and querying the database using the SimplySQL module (https://www.powershellgallery.com/packages/SimplySql/1.8.0).

The connection properties are very simple and allow connections to multiple database types, including MySQL.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.