In my previous post , I went through how to provision a MySQL database for an existing website. Now, that you have a provision a database for your site the next step is to connect the two of them together. Currently there is no way to connect a new database to an existing website using the Azure portal. If you are in this situation before you will need to manually to this using some sort of cloud connected web development tool like Web Matrix .
Getting Rid of HTTP 500
The first thing you might want to do is update the connection string using the Azure portal. Follow the steps below to reset the data connection
- Click show connection string
- Edit information with: database name , connection string , and type of database.
Format of connection string: Database= database name; Data Source=us-cdbr-azure-northcentral-a.cleardb.com;User Id= series of letters and numbers;Password=******.
If you try to access your site after you will notice that you still get the HTTP 500 response.
The Answer ! WebMatrix
I tried a lot of hair pulling solutions like Azure powershell commands, and FTP clients before I thought about using WebMatrix 3. When you initially signup for an Azure Subscription you are going to download suite of tools including WebMatrix3.
WebMatrix3 is a free tool that provides easy access to azure websites. This tool makes it easier to find and open your site files, as well as seamless transition between remote and local versions of the site.
Configuring your database
Step 1 : Access your site
- Start WebMatrix3 (For Download)
- Select MySites from the quick start menu.
- Select the site you are working on
Step 2 : Check Compatibility
- Select the remote , then click on check compatibility
- You will notice an alert icon besides database availability.
- Click on settings besides the check compatibility icon.
- Edit the connection string with information above. (format should be something like this Database= database name; Data Source=us-cdbr-azure-northcentral-a.cleardb.com;User Id= series of letters and numbers;Password=****** )
- Click save
- Click Validate connection
Step 3: Updating the configuration php file
- Click open remote view
- Open wp-config.php file and edit the following lines of code below
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'ENTER DB_NAME'); /** MySQL database username */ define('DB_USER', 'ENTER DB_USER'); /** MySQL database password */ define('DB_PASSWORD', 'ENTER DB_PASSWORD '); /** MySQL hostname */ define('DB_HOST','us-cdbr-azure-northcentral-a.cleardb.com'); /** NOTE HOST CHANGES DEPENDING ON ENDPOINT LOCATION */
If you have just lifted up your hands up in victory your website is up and running. My last two post described how I re-provisioned, backed-up, and reconnected a database to my existing blog .
I hope this helped & happy blogging!