# Azure database hosting
# Getting student credit
We will host a database in the cloud using Microsoft Azure. Azure is not a free product/service, so we need to request free student credit. These first steps guide you through the process of requesting free student credit for Microsoft Azure.
Go to https://azure.microsoft.com/en-us/free/students (opens new window) and click on the green 'Start free' button.
In case you’re not logged in yet, you well be sent to the sign in page. Sign in with your Thomas More account.
On the page that opens, fill in your personal information. In the Country field, choose 'Belgium' (no matter which country you're from). Once you have selected Belgium, start typing our school’s name in the ‘School name’ field. Choose 'Thomas More – Campus Geel (Geel)'.
At the bottom of the page, click on the button 'Verify academic status'.
In the page that opens, fill in your personal information. This time, choose your country of origin (= the country on your passport / identity card).
Accept the 'customer agreement' at the bottom of the page and next click on 'Sign up'. You will now be led to the Overview page of Microsoft Azure (this might take some time). Check that you now have available credits worth $100.
# Setting up your MySQL database in the cloud
We are going to use Microsoft Azure to create a MySQL database in the cloud. This way, it is always available and we don't have to have our own server running to access the data.
# Create a resource group
Every resource (application, database, active directory, etc.) on Azure has to be part of a resource group. A resource group is a collection of services that belong together.
Follow these steps to create a new resource group:
On your home page, click the Resource groups item. (If it does not show up here, click on 'More services' and search it there.)
Click the Create button
Give your resource group a fitting name and set its location to (Europe) West Europe
Click Review + create and then Create at the bottom of your window.
Your new resource group is now available
# Create a database server
Now that the resource group is set up, it's time to add a database server! For this course we are going to create a MySQL Flexible Server.
DO NOT CHANGE ANY OF THESE SETTING
Microsoft Azure is a paid service! The setting we give you in this setup will ensure that your database will last untill the end of the semester with the student credit that you get from Microsoft! If you alter any of the setting we give, you might end up with a more expensive product which will not last.
To create our very own server, follow these steps:
In the search bar at the top of your page, type in mysql and select Azure Database for MySQL flexible servers
Click Create and choose Flexible server
Enter following in the Project details
- select your newly made resource group from the dropdown list
- Give your server a fitting Server name
- Choose your region
- Select workload type For development or hobby projects
Then click the Configure server link
Here we will downgrade our server a bit more
- Select the Burstable computing tier
- Select Standard_B1s compute size
- Set the Storage size to the minimum of 20GiB
Click Save at the bottom of the page
Scroll down to the Authentication section
- Select the MySQL authentication only option
- Choose a fitting administrator username and password (do not forget your administrator username and password!)
Click Next : Networking at the bottom of the page
- Set the connectivity method to Public access
- Allow public access by setting the checkbox to checked
- Add the firewall rule + Add 0.0.0.0 - 255.255.255.255
Click Review + create at the bottom of the page
Your estimated cost should look like this. If your cost exceeds USD 10/month, you might get in trouble for your project
If everything looks fine, click the Create button at the bottom of the page
Your very own MySQL cloud server is now being made. This can take several minutes to complete.
On failed deploy
If the deployment of your server failed, we recommend trying another region to place your server in. Repeat the above steps with another region untill your deploy succeeds.
- Once your deployment is completed, click the button Go to resource to finish configuring you database
# Configuring the database
Disabling SSL on the server
For the purpose of this course, we will disable SSL on our server. This will give us less issues when developping. However, in actual databases for clients and projects, this is a not a good idea because you remove a piece of security.
The last steps we need to do are disabling SSL (see warning above) and creating the database
- First select Server parameters on your resource overview screen
- Search for secure and set the parameter require_secure_transport to OFF
- Click the Save button above the table to confirm
- Go back to your resource overview screen and in the side bar, select Databases
- Click the Add button
- In the sidebar that opened, give your database a fitting name
- Click Save
You now have a MySQL database ready for use! The next step is connecting to the database to add tables, columns, data, etc.
Adding databases
In Azure, you pay for the server! This means that you can add as many databases to this server as you like.
# Connecting to the database
To find out how to connect to your newly created database:
- Select Connect in the sidebar of your resource
- If you want to connect from MySQL workbench:
- select the MySQL Workbench tab and follow the instructions (similar to the instructions shown below).
- you can ignore the instructions for SSL since we disabled it
- select the MySQL Workbench tab and follow the instructions (similar to the instructions shown below).
Credentials
Beware that your connection information might be different than what's shown in this screenshot. The hostname and username might be different, depending on how you set up everything. Make sure you follow the instructions for your own database, don't blindly take over what's on the screenshot.
Good luck with your very own MySQL database in the cloud.