📜 ⬆️ ⬇️

Creating a MySQL database within Microsoft Azure for students

Most recently, Microsoft announced the provision of free cloud hosting for Microsoft Azure students . Within the program, the following resources are available to students: websites, WebAPI web services and SignalR, CMS Joomla, as well as MySQL databases (yes, MS SQL is not yet available).



A series of video tutorials from shwars on the basics of creating websites in WebMatrix, Visual Studio, and an example of deploying a Joomla site (which is also available in text form ) is available on the Microsoft Azure promotional website for students .
')
In this article I would like to add this series and describe how you can connect the MySQL database to a project on the .NET Framework. Since this process combines several entities (Azure, MySQL and Visual Studio), it will be described in as much detail as possible in pictures for beginner programmers.
Therefore, careful traffic!


So, in order to achieve the desired goal - we need to perform a series of simple actions:

Step one: create and configure a database in the Microsoft Azure portal
To add a database on the Microsoft Azure portal , go to the cloud resource creation menu and go to the “Data + Storage” section. MySQL is at the very bottom of the list:



Next, you need to set a number of simple settings:



Price category (20MB available):



Each Azure resource must be in a resource group. If you do not have such groups yet, create it:



In our case, simply give it a name unique to our account:



Geographical location - closest to us "Northern Europe":



See the terms of use and privacy statement:



Great, we entered all the necessary settings and we can create our database:



The creation process takes some time, and while the database is deployed - we see an animated icon:



Also, in the section of running operations, we see similar information:



After the database is created - we will see a notification:



Using the tile on the main page, we’ll go into the database properties:



And go to the full list of parameters:



We are interested in “Host Name”, “Port”, “Username” and “Password”. We need them to access the database.




Step Two: Install MySQL Workbench to work with the database
Working with MySQL is possible using the built-in tools of Visual Studio, however, I advise you to use a native tool for this database:



Click the desired link:



We fall on the official download site. Scroll down:



Select the bit of your operating system:



In my case, this is Windows 10 x64:



We will be kindly offered to join the community, but this is not necessary. We can immediately go to download:



Download starts:



Run the installer:



We click "Next-Next" by ticking:



After the installation is complete, we start the MySQL Workbench:



Since we will have to connect to MySQL more than once, we will create a connection template:



Create a new template:



Go to connection options:



Now we’ll enter the data we saw in the Azure Management Console. And in order to not enter the password every time you connect, we will save it in the Workbench password storage:



Enter the password:



Now we can check whether we entered everything correctly:



Fine! Connection established:



Now when you start Workbench, we can connect to the database in one click:



Let's wait a bit:



This will open the classic database management environment. Let's pass to our DB:



As you can see, the database is empty. You can create your first table using the SQL CREATE TABLE query in the Query window:




Step Three: Install MySQL Data Provider
Good. Now we need to install the correct Data Provider so that we can work with MySQL from .NET:



Click on the desired link:



Scroll down:



Choose the bit of your operating system:



We proceed immediately to download:



Download begins:



Run the installer:



We click "Next-Next" by ticking:




Step Four: Establish a connection to MySQL via Server Explorer in Visual Studio
Fine! We are at the finish line. Run Visual Studio:



Let's create the simplest Web project:



In my case it will be an empty ASP.NET solution:



Now let's go to the "Server Explorer" to establish a connection:



We see our subscription:



Click on the "Connect to database" icon:



As you can see, now MySQL is available in the list of available providers:



Let's enter our credentials from the Azure Management Console and check availability:





Now from the drop-down list we see our database:



We establish connection:



Fine! Finally, we have full access to our MySQL database hosted in the Azure cloud from Visual Studio!




As you can see, the whole procedure is quite simple and transparent. I hope the article will be useful for novice programmers interested in web development or planning to create their first backend for a mobile application.

Successful coding and interesting projects!

UPD: Added spoilers, I hope, because the abundance of images will cause less discomfort when scrolling.

Source: https://habr.com/ru/post/269275/


All Articles