Connecting existing Web App to Azure Database for MySQL (Preview)

2 minute read • May 16, 2017

mksunitha
The following steps show how to connect your existing web app on Azure App Service running on MySQL in-app or other MySQL solutions in Azure to Azure database for MySQL (Preview).

Before your begin

Log in to the Azure portal . Create a MySQL database on Azure Database for MySQL (Preview) service . For details , refer to How to create MySQL database from Portal or How to create MySQL database using CLI.

Firewall configuration

Azure database for MySQL provides tighter security using Firewall to protect your data. When using this service with App Service Web Apps , you need to keep in mind that the outbound IPs are dynamic in nature .
  1. To make sure the availability of your web app is not compromised , we recommend to all the rule to allow ALL IPs as shown in the image below.  Note: We are working with Azure database for MySQL (Preview) team for a long term solution to avoid allowing all IPs.  allowallrule
  2. You can explicitly add all the outbound IPs for your web app to MySQL server configuration . To learn more , see how to get outbound IPs for App Service.outboundip
App service infrastructure tries to  keep the outbound IPs the same as best as we can , but when recycle or scale operation occurs  it may change since we add new machines on every region frequently to increase our capacity to server customers.  If this changes , the app will experience downtime since it can no longer connect to the database.   Keep this mind when choosing one of the option mentioned above.

SSL configuration

Azure database for MySQL (Preview) has SSL Enabled . If your application is not using SSL to connect to the database , then you need to Disable SSL on MySQL server. For details on how to configure SSL , See using SSL with Azure database for MySQL (Preview). ssldisable Note that some applications frameworks may not support SSL , hence check your application framework documentation on whether to disable or enable SSL.

Migrating from MySQL in-app database to Azure Database for MySQL (Preview)

You can migrate MySQL in-app database to Azure database for MySQL (Preview) using Export feature. Note in order to use this feature to export the database , you need to :
  • Disable SSL since the feature does not work with MySQL database connected via SSL.
  • Allow all IPs is configured on your MySQL server

App Service Back up and Restore features

Currently backup and restore feature does not work with SSL enabled for Azure Database for MySQL (Preview). Disable SSL if you are planning to backup/restore the database using App service backup feature . Azure database for MySQL (Preview) also offers backup feature , for more details see here.