A little freebie in Microsoft Azure or create a free SQL Database in the cloud

Hello everyone, this small manual will be useful for those who want to use SQL Database in the Azure cloud, but for a number of reasons it still doesn’t. As you know, Microsoft Azure is a cloud hosting that has recently been free for students. Today I want to talk about a method similar to what was described in an article by my colleague MSP (but slightly different) how to use SQL Database in the cloud for free.



The Microsoft Azure cloud has long been able to host free Azure Web Sites. Separately, I will say that students in the DreamSpark programcan access Azure Web Sites, MySQL Database (up to 32 mb) and some other features of the Azure cloud. Recently, Azure SQL Database is available for students through a DreamSpark subscription, but only up to 32 MB. But, if you can’t get more for free, but really want to, then you can.
SQL Server Compact will come to help us in creating a project with a free SQL Database in the cloud, but first things first.

Microsoft® SQL Server ™ Compact 4.0 is a free, built-in database that can be used to create ASP.NET websites and applications for Windows computers. SQL Server Compact 4.0 takes up little space and supports private deployment of the executable module in the application folder, simplifies development in Visual Studio and WebMatrix, and provides convenient schema and data migration to SQL Server.



The SQL CE database is in a single .sdf file. As for the restrictions on the size of such a database, it is as much as 4 GB! The .sdf file can simply be copied to the target system for deployment, which is what we will use.

First, take a project that already uses the SQL Server database or create a new one.
I will use a small off-the-shelf project that uses SQL Server and Entity Framework.

First, through NuGet, install “EntityFramework.SqlServerCompact”. This is enough, because upon installation, the remaining necessary packages will load themselves.



Next, you need to change the connectionString and make it look:


NB the database format is exactly * .sdf



After we start the project, and the SQL CE database file appears in the App_Data folder of our application.



The next step is to include this file in the project. To do this, add the * .sdf file to the App_Data folder in Visual Studio.



Now you are ready to deploy the application in the cloud. As mentioned earlier, Azure can host free Azure Web Sites. A site can be created directly from Visual Studio during deployment setup, but to avoid errors, I recommend doing this through the Azure portal .





Next, you need to return to Visual Studio and publish the application by selecting the created web application in the second step.





After successful publication, the site will open automatically and you can see the result.



Microsoft SQL Server Compact works fine in Azure, but this method with deploying databases in the cloud can be applied to various ASP .NET hosting services, where SQL databases are expensive / only paid.

This method has one drawback compared to the method described in this article , namely, working with SQL * .sdf databases is not as convenient as working with * .mdf. To view the contents of the * .sdf database, I use LINQPad 5 .

To do this, I download the database file (via the VS Online extension installed in Azure) and upload it to LINQPad.







That's all! As a student, I can say that this kind of “freebie” is very attractive, because the SQL Server Database does not lie on the road in a 4 GB cloud!

Also popular now: