Get in touch with us!

Azure MySQL In App (preview) + WordPress

Microsoft recently announced a new feature in Azure Web App service called MySQL In App, as you can tell by the name this is an PaaS version of MySQL and it’s not ClearDB.
The service is now in public preview and I like to show you how easy it is to use.

First of we create a Web App in the Azure portal, give it a name and location an click create.
AzureMySQL (1)
When the web app is created we want to go into the settings blade “MySQL In App (preview)”, in here turn the feature On.
Finnish by clicking Save.
AzureMySQL (2)

The simplest way to show this in action is to deploy a WordPress site to the web app and we are going to do this by simply cloning an external git repository.
Go to deployment options and select External Repository.
AzureMySQL (3)

Enter the git repository for WordPress URL and branch.
AzureMySQL (4)

While we wait for the repository to clone to our web app lets check if mysql has started.
AzureMySQL (5)

Azure Portal have an build-in process explorer for web applications and in here you will see the mysqld process as soon as the service is provisioned.
AzureMySQL (6)

If the process is running you will be able to go back to MySQL in App blade and click Manage.

AzureMySQL (7)

This will open phpmyadmin in a new tab. If you get prompted for password it is user:azure password:password
AzureMySQL (8)
I’ve seen people freak out about this. Why is the password password?! OMG OMG!!
Wait, check the URL, if you haven’t seen before “bing it”.
The site is protected by Azure AD Pre-Authentication and the permissions are set from RBAC(IAM) in the Azure portal.

AzureMySQL (9)
If you take the same URL from another browser you will see what I mean, there is no need to have a more complex password in MySQL.

The WordPress repository is now successfully cloned.

AzureMySQL (10)

In order to use In app MySQL the right way we will never use any hostname, database, username or password manually to configure any application. Instead you want to get the connection string by code from the host. You want to do this because the hostname can change when scaling and password get renewed (in the future).
Information how can be found here
But I will show you how to do it in WordPress. First we need an editor, so why not use the one in the portal. Open App Service Editor.
AzureMySQL (11)
Rename wp-config-sample.php to wp-config.php
AzureMySQL (12)

Add the code like it’s shown in the picture bellow.

/*Add at the begining of the file*/

$connectstr_dbhost = '';
$connectstr_dbname = '';
$connectstr_dbusername = '';
$connectstr_dbpassword = '';

foreach ($_SERVER as $key => $value) {
 if (strpos($key, "MYSQLCONNSTR_localdb") !== 0) {
 $connectstr_dbhost = preg_replace("/^.*Data Source=(.+?);.*$/", "\\1", $value);
 $connectstr_dbname = preg_replace("/^.*Database=(.+?);.*$/", "\\1", $value);
 $connectstr_dbusername = preg_replace("/^.*User Id=(.+?);.*$/", "\\1", $value);
 $connectstr_dbpassword = preg_replace("/^.*Password=(.+?)$/", "\\1", $value);

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', $connectstr_dbname);

/** MySQL database username */
define('DB_USER', $connectstr_dbusername);

/** MySQL database password */
define('DB_PASSWORD', $connectstr_dbpassword);

/** MySQL hostname : this contains the port number in this format host:port . Port is not 3306 when using this feature*/
define('DB_HOST', $connectstr_dbhost);
AzureMySQL (13)

Now test it by going to the Web App URL
AzureMySQL (14)

How simple is that!? I love it!
AzureMySQL (15)

Since it’s in preview it also free so why not make the web free as well.
AzureMySQL (16)

It works 🙂
AzureMySQL (17)


If you want this feature please try it out and spread the word. It’s not for production, yet and it’s single instance but hopefully it will become as good as Azure SQL.

Jon Jander @MeapaX

Submit a Comment

Your email address will not be published. Required fields are marked *

Starkare tillsammans

Bolag inom bÄde publik och offentlig sektor efterfrÄgar en alltmer kostnadseffektiv, platsoberoende och sÀker digital arbetsplats. DÀrför gÄr nu Altitude 365 och Uclarity samman och bildar ett gemensamt specialistbolag.
FortsÀtt pÄ Altitude 365Kolla in Exobe

Altitude 365 + Uclarity – Årets Modern Work Partner!

Vinnaren Ă€r ett bra exempel pĂ„ hur en “Born in the Cloud” stĂ€ndigt förbĂ€ttrar sitt erbjudande, arbetar nĂ€ra och proaktivt med Microsoft för att hjĂ€lpa kunderna pĂ„ deras digitaliseringsresa. Plus att vi pĂ„ Microsoft verkligen ser fram mot den nya bolags-konstellationen (Altitude 365 + Uclarity) för ett “Starkare Tillsammans”.

Uclarity och Altitude 365 - Starkare tillsammans

Uclarity Àr specialister pÄ digitala möten, telefoni, kontaktcenter och digitalt arbetssÀtt. Altitude 365 Àr specialister pÄ sÀkerhet, mobilitet och hur bolag kan optimera resan till Microsoft365. Nu gör vi gemensam sak och bildar bolag tillsammans.

– Pandemin har tydliggjort behoven av en modern digital arbetsplats och vi har diskuterat ett samgĂ„ende med Altitude 365 under en lĂ€ngre tid. VĂ„ra kunder har behov av specialistkompetens och tillsammans blir vi en ledande specialist inom Digital Workplace-omrĂ„det, sĂ€ger Niklas Olsson Hellström, VD Uclarity AB.

Tommy Clark, Partner, Altitude 365, kommenterar:
– Inget bolag köper det andra utan bĂ„da bolagen fĂ„r lika stora delar i det nya bolaget. VĂ„r ledstjĂ€rna Ă€r att vi blir starkare tillsammans och att vi kan hjĂ€lpa vĂ„ra kunder under hela deras resa.
MÄlet med sammanslagningen Àr att kunna hjÀlpa kunder med bÄde teknik och effektiva arbetssÀtt.

– Det Ă€r dĂ„ vĂ„ra kunder fĂ„r önskad effekt av sin investering i den digitala arbetsplatsen, sĂ€ger Niklas Olsson Hellström.

BĂ„da bolagen har svenska och internationella kunder frĂ„n bĂ„de privat och offentlig sektor. Sammanslagningen resulterar i en organisation pĂ„ 50+ anstĂ€llda baserade i Stockholm, Örebro och Göteborg.

För frÄgor, vÀnligen kontakta;
Tommy Clarke, Partner, Altitude 365 AB, 0703-593854,
Niklas Olsson Hellström, VD, Uclarity AB, 0734-198016,

FortsÀtt pÄ Altitude 365Kolla in Exobe