Azure Database for MySQL Deployment task

Azure DevOps Services

Use this task to run your scripts and make changes to your database in Azure Database for MySQL. Note that this is a preview version. The Azure Database for MySQL Deployment task only works with Azure Database for MySQL Single Server.

YAML snippet

# Azure Database for MySQL deployment
# Run your scripts and make changes to your Azure Database for MySQL
- task: AzureMysqlDeployment@1
  inputs:
    ConnectedServiceName: # Or alias azureSubscription
    ServerName:
    #DatabaseName: # Optional
    SqlUsername:
    SqlPassword:
    #TaskNameSelector: 'SqlTaskFile' # Optional. Options: SqlTaskFile, InlineSqlTask
    #SqlFile: # Required when taskNameSelector == SqlTaskFile
    #SqlInline: # Required when taskNameSelector == InlineSqlTask
    #SqlAdditionalArguments: # Optional
    #IpDetectionMethod: 'AutoDetect' # Options: AutoDetect, IPAddressRange
    #StartIpAddress: # Required when ipDetectionMethod == IPAddressRange
    #EndIpAddress: # Required when ipDetectionMethod == IPAddressRange
    #DeleteFirewallRule: true # Optional

Arguments

Argument Description
ConnectedServiceName
Azure Subscription
(Required) This is needed to connect to your Azure account.

To configure a new service connection, select the Azure subscription from the list and click 'Authorize'.

If your subscription is not listed or if you want to use an existing service principal, you can set up an Azure service connection using the 'Add' or 'Manage' buttons.

Argument alias: azureSubscription
ServerName
Host Name
(Required) The name of your Azure Database for MySQL server.

Example: fabrikam.mysql.database.azure.com

The server name is provided in the Azure portal on the 'Overview' blade of your Azure Database for MySQL server resource.

When you connect using MySQL Workbench, this is the same value that is used for 'Hostname' in 'Parameters'.
DatabaseName
Database Name
(Optional) The name of the database. If specified, the task attempts to create the database if it does not exist.

If not specified, ensure that the database is referenced in the supplied SQL file or inline SQL, where needed.

Note: MySQL database names are case-sensitive.
SqlUsername
Server Admin Login
(Required) Azure Database for MySQL server supports native MySQL authentication.

You can connect and authenticate to a server with the server's admin login.

Example: Mysqladmin

When you connect using MySQL Workbench, this is the same value that is used for 'Username' in 'Parameters'.
SqlPassword
Password
(Required) The password for the username supplied to the SqlUsername argument. If you don't recall the password, you can change the password in the Azure portal. It can be a variable defined in the pipeline.

Example: $(password)

Also, you may mark the variable type as 'secret' to secure it.
TaskNameSelector
Type
(Optional) Accepted values:

- SqlTaskFile (default), for use with the SqlFile argument
- InlineSqlTask, for use with the SqlInline argument.

Note: These values are case-sensitive.
SqlFile
MySQL Script
(Required) Full path of the script file on the automation agent or on a UNC path that's accessible to the automation agent.

Example: \BudgetIT\DeployBuilds\script.sql

You may also use predefined system variables, for example $(agent.releaseDirectory).

The given path is expected to reference a SQL file that contains SQL statements.

Note: The MySQL client prefers Unix style paths so, from version 1.183.0, the task will convert Windows style paths to Unix style paths. Example: From c:\foo\bar\myscript.sql to c:/foo/bar/myscript.sql. When the task is used on Linux platforms, paths remain unchanged. There is no need to escape special characters in paths.
SqlInline
Inline MySQL Script
(Required) Enter the MySQL script to execute on the selected database.

Example: UPDATE my_table SET my_col = 'foo';
SqlAdditionalArguments
Additional MySQL client options
(Optional) Additional options supported by the MySQL client.

These options are applied when you execute the file on the database in Azure Database for MySQL.

Examples include:
- --comments to strip comments sent from the client to the server.
- --quick to prevent result caching.
- --xml to output results as XML.

All available options are described in the MySQL client documentation.
IpDetectionMethod
Specify Firewall Rules Using
(Required) For successful execution of the task, we need to enable administrators to access the Azure Database for MySQL server from the IP address of the automation agent. By selecting auto-detect, you can automatically add a firewall exception for a range of possible IP addresses for the automation agent, or you can explicitly specify the range.

Accepted values:

- AutoDetect to auto-detect the automation agent's public IP address.
- IPAddressRange to explicitly specify the IP address range to configure. Set the IP address range using the StartIpAddress and EndIpAddress parameters.

Note: These values are case-sensitive.
StartIpAddress
Start IP Address
(Required) The starting IP address of the automation agent machine pool.

Example: 198.51.100.1
EndIpAddress
End IP Address
(Required) The ending IP address of the automation agent machine pool.

Example: 198.51.100.65
DeleteFirewallRule
Delete Rule After Task Ends
(Optional) If selected, the added exception for IP addresses of the automation agent is removed for the corresponding database in Azure Database for MySQL.

Open source

This task is open source on GitHub. Feedback and contributions are welcome.