serverless
4 TopicsAzure Database for MySQL bindings for Azure Functions (General Availability)
We’re thrilled to announce the general availability (GA) of Azure Database for MySQL Input and Output bindings for Azure Functions—a powerful way to build event-driven, serverless applications that seamlessly integrate with your MySQL databases. Key Capabilities With this GA release, your applications can use: Input bindings that allow your function to retrieve data from a MySQL database without writing any connection or query logic. Output bindings that allow your function to insert or update data in a MySQL table without writing explicit SQL commands. In addition you can use both the input and output bindings in the same function to read-modify-write data patterns. For example, retrieve a record, update a field, and write it back—all without managing connections or writing SQL. These bindings are fully supported for both in-process and isolated worker models, giving you flexibility in how you build and deploy your Azure Functions. How It Works Azure Functions bindings abstract away the boilerplate code required to connect to external services. With the MySQL Input and Output bindings, you can now declaratively connect your serverless functions to your Azure Database for MySQL database with minimal configuration. You can configure these bindings using attributes in C#, decorators in Python, or annotations in JavaScript/Java. The bindings use the MySql.Data.MySqlClient library under the hood and support Azure Database for MySQL Flexible Server. Getting Started To use the bindings, install the appropriate NuGet or npm package: # For isolated worker model (C#) dotnet add package Microsoft.Azure.Functions.Worker.Extensions.MySql # For in-process model (C#) dotnet add package Microsoft.Azure.WebJobs.Extensions.MySql Then, configure your function with a connection string and binding metadata. Full samples for all the supported programming frameworks are available in our github repository. Here is a sample C# in-process function example where you want to retrieve a user by ID, increment their login count, and save the updated record back to the MySQL database for lightweight data transformations, modifying status fields or updating counters and timestamps. public class User { public int Id { get; set; } public string Name { get; set; } public int LoginCount { get; set; } } public static class UpdateLoginCountFunction { [FunctionName("UpdateLoginCount")] public static async Task<IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = "user/{id}/login")] HttpRequest req, [MySql("SELECT * FROM users WHERE id = @id", CommandType = System.Data.CommandType.Text, Parameters = "@id={id}", ConnectionStringSetting = "MySqlConnectionString")] User user, [MySql("users", ConnectionStringSetting = "MySqlConnectionString")] IAsyncCollector<User> userCollector, ILogger log) { if (user == null) { return new NotFoundObjectResult("User not found."); } // Modify the user object user.LoginCount += 1; // Write the updated user back to the database await userCollector.AddAsync(user); return new OkObjectResult($"Login count updated to {user.LoginCount} for user {user. Name}."); } } Learn More Azure Functions MySQL Bindings Azure Functions Conclusion With input and output bindings for Azure Database for MySQL now generally available, building serverless apps on Azure with MySQL has never been simpler or more efficient. By eliminating the need for manual connection management and boilerplate code, these bindings empower you to focus on what matters most: building scalable, event-driven applications with clean, maintainable code. Whether you're building real-time dashboards, automating workflows, or syncing data across systems, these bindings unlock new levels of productivity and performance. We can’t wait to see what you’ll build with them. If you have any feedback or questions about the information provided above, please leave a comment below or email us at AskAzureDBforMySQL@service.microsoft.com. Thank you!Lesson Learned #320:Database 'XXX' on server 'xyz' is not currently available using ServerLess tier.
Today, we got a new service request that our customer faced the following error message: Database 'XXX' on server 'xyz.database.windows.net' is not currently available. Please retry the connection later. If the problem persists, contact customer support, and provide them the session tracing ID of '{XXXXX7B5-BFBE-437D-A34D-NNNNNN}'. (.Net SqlClient Data Provider)Learning from Expertise #8: Why cannot move SQL database from provisioned to serverless?!
Overview: We sometimes see customers cannot move their SQL database from provisioned compute tier to serverless while the scaling operation fails with error signature like: Failed to scale from General Purpose: Gen5, 2 vCores, 32 GB storage, zone redundant disabled to General Purpose: Serverless, Gen5, 2 vCores, 32 GB storage, zone redundant disabled for database: <database-name>. Error code: . Error message: An unexpected error occured while processing the request. Tracking ID: 'xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx' Resolution: In the beginning, you can switch to serverless compute tier only under the vCore model which provides a wide range of configuration controls and offers Hyperscale/Serverless to automatically scale your database based on your workload needs. When the scaling operation is failing with aforementioned error, this most likely due to a serverless limitation. For instance, enabling auto-pause for a serverless database is not supported if long-term retention (LTR backups) or geo-replication is enabled. The following features do not support auto-pausing, but do support auto-scaling: Geo-replication (active geo-replication and auto-failover groups). Long-term backup retention (LTR). The sync database used in SQL Data Sync. Unlike sync databases, hub and member databases support auto-pausing. DNS alias created for the logical server containing a serverless database. Elastic Jobs, when the job database is a serverless database. Databases targeted by elastic jobs support auto-pausing, and will be resumed by job connections. In case any of these features are in-use, then auto-pausing must be disabled and the database will remain online regardless of the duration of database inactivity. For more information regarding Serverless, you can refer to Azure SQL DB documentation: Serverless compute tier - Azure SQL Database | Microsoft Docs I hope you find this article helpful. If you have any feedback please do not hesitate to provide it in the comment section below. Ahmed S. Mazrouh4.4KViews0likes0Comments