Free Azure SQL Database

During the development of a data-driven application, we can usually make do with a small database to store the data we’ll need while we develop. Once we move the application to staging and then to production we might want to store a larger amount of data or want high throughput.

If our solution requires the use of an Azure SQL database, then the smallest and cheapest database we can get is on the Basic pricing tier with 5 DTUs and 100 MB of storage. For this database, we will be paying around $5/month (USD).

We can see this when we are adding a new SQL Database and then specify the size:

 

While $5/month (USD) is not a considerable amount of money, we might simply want a cheaper alternative.

Fortunately, by following a series of simple steps we can provision a single Azure SQL database with 32 MB of data and 5 DTUs for free!

Mobile App

Rather than going to the portal and creating an Azure SQL database, we’ll instead first create a new Mobile App:


Once the Mobile App has been created, we’ll select it in the portal and click the “Quickstart” option in the Mobile App blade. This will bring up a number of different Quickstart templates to choose from:

Since we won’t complete each of the steps in Quickstart, it doesn’t really matter which template we choose, but for this demo we’ll select “Windows (C#)”.

This brings up the Quickstart blade where the first step is to “Connect a database”.

Clicking on Step 1 will bring up the Data Connections blade. Since we don’t yet have a data connection to choose from, we’ll  click “Add” and on the “Add data connection” blade select “SQL Database” as the Type and click on “Configure required settings” to bring up the Database blade.

In order to configure the SQL Database, we’ll need to go through a couple of blades to create a new database and create a new database server:

With the database configured, we now get to specify the pricing tier. Upon clicking on “Pricing tier” option, in addition to seeing the same pricing tiers as before, we have now unlocked the Free pricing tier:

We can now “Apply” the Free pricing tier, “Select” the SQL Database we just configured and “OK” the new data connection we just created. This will begin the provisioning of the SQL Server and SQL Database. Once everything is provisioned, your resource group will show the four new resources:

At this point, you can remove the Mobile App and the App Service plan and keep the free database.

Limitations

This process will allow you to get up to one free Azure SQL database per region. If you attempt this same process to create another free database in the same region, you will receive the following error:

As you can see from the error message, you can create another free database in a different region or if you want the same region, you will need to use a different subscription.

Summary

While 32 MB of data is not much, it is usually enough when you are just getting started. Also, this being an Azure SQL database, you can easily scale up when you outgrow the 32 MB and 5 DTU limits.

I would love to hear how you make use of the free Azure SQL database. Please comment below and let me know how you used the database and if you ever needed to scale up.

Preparing to pass Azure 70-533 Implementing Microsoft Azure Infrastructure Solutions certification exam

[This post is a recap of what I used to prepare to pass the Azure 70-533 certification. For more information about the exam, visit BuildAzure.]

I have been developing on the Microsoft web stack for well over 15 years and while I consider myself an expert in several Microsoft technologies, I had never gotten around to having a third-party validate my self-proclaimed “expertise”.

I had already been working on Azure for a couple of years and felt this would be the perfect platform where a certification could come in handy.

With this being my first ever certification, I was a bit lost as to where to start. My options for an Azure certification were:

  • Developing Microsoft Azure Solutions (70-532)
  • Implementing Microsoft Azure Infrastructure Solutions (70-533)
  • Architecting Microsoft Azure Solutions (70-534)

Fortunately, I came across Chris Pietschmann’s guide on the Azure certification exams. His guide showed me how the 70-532, 70-533, and 70-534 all fit together and it was at this point that I knew I wanted to take the 70-532 and 70-533.

Choosing to take the 70-533

I felt pretty comfortable with Azure’s Platform as a Service (PaaS) offerings since I had previously developed solutions on Cloud Services, Websites and more recently Web Apps, but the Infrastructure as a Service (IaaS) side was a bit alien to me. This should have naturally lead me to take the 70-532 first, however, when I looked up the courses offered on Pluralsight to make use of my subscription, the only complete Azure learning path was for the 70-533 (Implementing Microsoft Azure Infrastructure Solutions (70-533)). This learning path was made up of 7 courses that covered each topic on the infrastructure exam.

Studying for the 70-533

Using Pluralsight

I began the training path in August of 2016 and would squeeze in a couple of modules whenever I had a chance. It was not until late November/early December that I decided to get serious about studying and managed to complete the videos before the end of the year:

Some time in November, Microsoft announced that the 70-533 exam would get a refresh and use ARM template deployment model instead of the “Classic” approach, which is what the training material had mostly been based on.

Using Opsgility

I’m not really sure how I came upon Opsgility, but after I soon discovered that their 70-533 training material was updated to use ARM deployment model I decided to make use of their free trial.

Practice Exam

The registration for the Azure certification exam included a practice exam along with a test and a retake. The practice exam was administered by MeasureUp. Initially, I thought I had one chance to take the practice exam, but it turns out, I had a one-month access to retake the practice exam!

As evident from the results of my first practice exam, my Azure experience centered around App Services. While the results were a bit disappointing, the breakdown allowed me to pinpoint what sections I should focus on; clearly Active Directory and Virtual Machines.

Results of my initial 70-533 practice exam
Results of my initial 70-533 practice exam

Pluralsight vs. Opsgility

When I initially started preparing for the 70-533 I wanted to make use of the Pluralsight subscription I was already paying for, so I didn’t look any further. However, after Microsoft refreshed the exam to use ARM deployment model I knew I had to find updated training material.

Overall, Tim Warner and Razi bin Rais provided a good overview of each topic, however, I don’t think that I would have signed up for a Pluralsight subscription based on their 70-533 offering.

On the other hand, Opsgility training videos provided a good depth of information and were easy to follow, I think following their hands-on lab are what mainly helped me pass the exam.

Results

In early January I took my first certification exam and I’m happy to announce that I passed! Passing this exam earned me the Specialist: Implementing Microsoft Azure Infrastructure Solutions certification.

Specialist: Implementing Microsoft Azure Infrastructure Solutions

Volunteering at a Hackathon

In July of last year, I had the opportunity to volunteer at an all-day hackathon organized by Teens Exploring Technology (TxT). The concept was simple: Take a coding event to a lower-income community that is generally not represented in the tech industry.

The event was hosted in Nickerson Gardens’ activity center, which coincidentally, is about three blocks from where I grew up. At the event, there were approximately 80 students with several dozen volunteers. I was joined by another veteran programmer and we were paired with five kids ranging from 13 to 16. Most of them had grown up with access to computers at school, but none had any programming experience.

Our task was to help them develop a simple website or mobile app. We only had eight hours, so we opted to build a website.

Helping with HTML

To introduce them to HTML, I began by writing boilerplate HTML on a small board which they simply copied. I then had them each write their name in the <title>  and in the <body> . After which, they saved their changes and opened the file in a browser. Their faces lit up with excitement the moment the browser opened up and they were able to see their name on the page.

Seeing their expressions was an extremely rewarding feeling for me and reminded me of when I started programming of how happy I was to see my work on the screen.

We continue coding throughout the day and introduced them to additional tags, added Bootstrap to the mix and a bit of JavaScript.

 

Video Recap

Recently, Txt posted a video from the event and to my surprise, it includes me at the beginning helping out the kids with simple HTML.

 

Continue to Volunteer

I had a great time at the event and hoped that we left even a small impact on the kids. TxT is once again hosting another Hustle N’ Code hackathon next month, which I will again be volunteering.

First Impressions of Pluralsight Assessments

Recently, Pluralsight began allowing their subscribers to take assessments on specific topics. Assessments are a quick way for subscribers to test their knowledge on a select number of topics, ideally, ones that they watched on PluralSight.

What makes these tests unique is that the questions that subscribers are presented with are based on how well they answered the previous question. Answer a question correctly and the next question will be more difficult. Conversely, answer incorrectly, and the next question will be easier. In addition, each question has a countdown timer indicating the amount of time the subscriber has to answer the question.

If I’m not mistaking, this technology comes from PluralSight’s purchase of Smarterer in 2014.

Before an assessment goes live, it remain in beta until at least 50 tests are completed. I’m assuming this is so they can re-calibrate the difficulty rating of each question and perhaps adjust how much time the subscriber is given to answer each question.

After the assessment, based on how the subscriber scored, they are recommended a list of courses from the Pluralsight library they should watch.

Overall Impression

Personally, I really enjoyed taking several assessments on topics I felt strong in and the ability for tests to adapt based on how well a question was answered makes it just challenging enough to be fun. However, I feel that the countdown timer is a bit of a distraction and I feel rushed to answer a question. My approach now is to first look at the time and based on the amount of time I have, either speed read the question and possible answers or take my time and carefully read.

I was able to achieve decent scores in several of the assessments which I wish I could publicly share. This is a feature request I have made to Pluralsight, so hopefully that gets eventually implement. Until then, here are my scores:

MVC 5MVC 5 JavaScriptJavaScript
HTML5HTML5 AngularJSAngularJS

Strongly Typed Views in MVC

In ASP.NET MVC, we have a couple of options for passing data from a controller to a view:

  • ViewData
  • ViewBag
  • View-specific data model

ViewData

The ViewData  property is on the ControllerBase  which all controllers derive from and is accessible from both a controller and a view. It is of type ViewDataDictionary , which implements IDictionary<string, object> . To pass any piece of information to a view using the ViewData , we simply set the value in an action method:

Then, from within the view, we access the value by using the same key:

ViewBag

The ViewBag  is essentially a wrapper around the ViewData dictionary that uses dynamics to allow us to access the data using properties off of the ViewBag property rather than accessing each value by it’s key name. This property too, is off on the ControllerBase.

Then, from the view, we access the same property:

Both of these approaches allow us to pass in information to a view without creating a new class or adding a property to an existing class, however there are several disadvantages with both approaches:

No standard set of properties that get passed into the view
Since the data is passed into the view using essentially a dictionary, there is no way to enforce/ensure that expected values are provided. As such, if we wanted to use a common _Layout page to display the number of unread messages, the _Layout page would have to read the dictionary using a string-based key and check if an item is returned using that key.

In addition, since ViewData is a Dictionary<string, object> , whenever we read a value, we must first check if it is null, and then try to typecast it into a type that we expect it to be.

No intellisense
When working on the view and need to read a property, you will need to look back at the action method to see what the property was called instead of allowing Intellisense to help you find the property.

No compile time checking of our views
Because the ViewData and ViewBag are just dictionaries, there is no way for the compiler to know if a property being accessed from the view was ever set in the action method. It is only at run-time that the bug will present itself.

—–

A Better Approach

Using strongly-typed views that inherit from a base view model we can avoid the problems I just listed. Having the base view model will give us a common set of properties that _Layout page can depend on, we’ll have Intellisense when reading a property from the model and if we turn on view compilation, we’ll also get compile-time checking.

The Model

/Models/ViewModels/BaseViewModel.cs

Base class that all view models will inherit from:

/Models/ViewModels/Home/IndexViewModel.cs

Derived class that will be used by the Index view:

The Controller

/Controllers/BaseController.cs

Base controller that all controllers will derived from. It contains a protected method that will be used to set the standard BaseViewModel  properties. When calling this method, the caller has the option to provide a page title. Also, note that this method is responsible for retrieving and setting the number of unread messages instead of requiring each action method to set this value.

/Controllers/HomeController.cs

The HomeController  will derive from the BaseController  and call the base method to set the properties of the base view model. The Index action method will only deal with setting additional properties needed by its view.

The View

/Views/Home/Index.cshtml

The view works directly with the view model that is specific for this view and does not have to worry about properties on the base view model. Those properties will be handled by _Layout.cshtml

/Views/Shared/_Layout.cshtml

The _Layout page can now access the properties on the base view model in a strongly-typed way with Intellisense and compile-time checking:

Summary

Using a BaseViewModel  we have a structured way of passing data from the controller to the view. Using a BaseController  allows us to move the logic responsible for setting common properties into one centralize place. From the views we can leverage Intellisense to help us access the correct properties from our model and get compile-time errors whenever we access properties that do not exist in our model.