Overview of Azure Database for MySQL bindings for Azure Functions

Choose a programming language

This set of articles explains how to work with Azure Database for MySQL bindings in Azure Functions. Azure Functions supports input bindings and output bindings in general availability. For the preview, Azure Functions supports trigger bindings for Azure Database for MySQL.

Action Type
Read data from a database Input binding
Save data to a database Output binding
Trigger a function when a change is detected in a MySQL table (preview) Trigger binding

Install the extension

The extension NuGet package that you install depends on the C# mode you're using in your function app:

Functions run in an isolated C# worker process. To learn more, see Guide for running C# Azure functions in an isolated worker process.

Add the extension to your project by installing this NuGet package.

dotnet add package Microsoft.Azure.Functions.Worker.Extensions.MySql --version 1.0.3-preview

Install the bundle

The extension for Azure Database for MySQL bindings is part of the v4 extension bundle. This bundle is specified in your host.json project file.

Preview bundle v4.x

You can use the preview extension bundle by adding or replacing the following code in your host.json file:

{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
    "version": "[4.*, 5.0.0)"
  }
}

Install the bundle

The extension for Azure Database for MySQL bindings is part of the v4 extension bundle. This bundle is specified in your host.json project file.

Preview bundle v4.x

You can use the preview extension bundle by adding or replacing the following code in your host.json file:

{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
    "version": "[4.*, 5.0.0)"
  }
}

Install the bundle

The extension for Azure Database for MySQL bindings is part of the v4 extension bundle. This bundle is specified in your host.json project file.

Preview bundle v4.x

You can use the preview extension bundle by adding or replacing the following code in your host.json file:

{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
    "version": "[4.*, 5.0.0)"
  }
}

Update packages

You can use the preview extension bundle with an update to the pom.xml file in your Java Azure Functions project, as shown in the following snippet:

<dependency>
<groupId>com.microsoft.azure.functions</groupId>
<artifactId>azure-functions-java-library-mysql</artifactId>
<version>1.0.1-preview</version>
</dependency>

MySQL connection string

Azure Database for MySQL bindings for Azure Functions have a required property for the connection string. These bindings pass the connection string to the MySql.Data.MySqlClient library and provide support as defined in the MySqlClient ConnectionString documentation. Notable keywords include:

  • server: The host on which the server instance is running. The value can be a host name, IPv4 address, or IPv6 address.
  • uid: The MySQL user account to provide for the authentication process.
  • pwd: The password to use for the authentication process.
  • database: The default database for the connection. If no database is specified, the connection has no default database.

Considerations

  • Azure Database for MySQL bindings support version 4.x and later of the Azure Functions runtime.
  • You can find source code for the Azure Database for MySQL bindings in this GitHub repository.
  • These bindings require connectivity to Azure Database for MySQL.
  • Output bindings against tables with columns of spatial data types GEOMETRY, POINT, and POLYGON aren't supported. Data upserts fail.

Samples

In addition to the samples for C#, Java, JavaScript, PowerShell, and Python available in the GitHub repository for Azure Database for MySQL bindings, more are available in Azure Samples.