helping a dev-ops newbie

I am a public transport commuter so I have about 30 minutes each journey on a bus every day. This is an ideal time to do some learning. I started using Babbel last year to learn some French for my holidays, but now I am hooked on pluralsight and I am currently following Scott Allen’s series on Azure. This list loads of great tips for a developer!

In one of the chapters he discusses automating azure something that I haven’t really been involved in personally but I have heard from more dev-opish people that it can be a bit of a pain using the azure resource managment templates ( ARM) as it is very easy to make mistakes and you don’t have any really good IDE to assist you. Enter Azure Resource Group projects for Visual Studio 2017. This is a great project template that lets you do most things required to automate a deploy of your infrastructure.

A Quick Guide


This is what you need
  1. Visual Studio 2017 (15.5.2 at the time of writing)
  2. Azure subscription


I already have a solution with a new web application in Visual Studio 2017 that I want to create some Azure infrastructure for, so that’s my starting point. You can however start from scratch with

file->new project

I then go to add new project, under the Cloud tab I select Azure Resource Group.

When prompted to select a template I have a plethora of options. I can start from a blank template or a number of predefined scenarios. I will Select Web app as I only have a web application that i want to create infrastructure for. Don’t worry as you can add resources at a later point.

The new project is added and once expanded the following files should be included

  • Deploy-AzureResourceGroup.ps1 A powershell script to run your deployment
  • WebSite.json a JSON file containing the actual resource template
  • WebSite.parameters.json A JSON file containing parameters for the resource group

Adding Resources

Okay! lets start with adding a few more resources. A web application will probably require some storage and we want to be able to set application settings for the environment.

Open the file WebSite.json, on the left hand side you should be able to see a tab called JSON outline, if its not there go to

View->Other Windows-JSON Outline

The JSON Outline contains several nodes from the template, lets start with adding Appsettings to the WebSite. Right click on the WebSite node and select AppSettings

Note that you want to add it to the “WebSite”

Now lets repeat the procedure and add a StorageAccount

The above steps will have updated your website.json with several new sections (you can se them in the JSON Outline)


So now we have the resources that our infrastructure require, Lets start parametrise our code so that we get some control of names etc.

Open the WebSite.json and via the Json Outline find the Parameters section

Lets start with add the following snippet, Don’t worry about the Greetings parameter it will be clear in a few steps.

"StorageAccountName": {
    "type": "string"
"StorageAccountType": {
    "type": "string",
    "defaultValue": "Standard_LRS",
    "allowedValues": [
    "WebSiteName": {
        "type": "string"
    "Greetings" : {
        "type": "string"
</pre> Open the WebSite.json and via the Json Outline find the Variables section and change the section to something like:
"variables": {
    "webSiteName": "[parameters('WebSiteName')]",
    "MyWebStorageName": "[parameters('StorageAccountName')]"
</pre> Open the WebSite.json and via the Json Outline find the Appsettings section And change to this snippet
"properties": {
    "Greetings": "parameters('Greetings')"
</pre> Now we have set up our template to use the parameters we require. Lets move on to see where these parameters will come from.Open up WebSite.parameters.json and replace the content it with 
    "$schema": "",
    "contentVersion": "",
    "parameters": {
        "hostingPlanName": {
            "value": "coolnewwebsitedevplan"
        "Greetings": {
            "value": "Hello from appsettings in dev"
        "WebsiteName": {
            "value": "coolnewwebsite"
        "skuName": {
            "value": "S1"
        "StorageAccountName": {
            "value": "coolnewwebsitedevstorage"
</pre>Now we have a parameter file that matches what our template expects and we have a way to move away from hard-coded values as these values will be inserted into WebSite.json when creating the resource during a deployment.  Deploying We are now ready to deploy our infrastructure to azure. You do this by right-clicking on the project in the Solution Explorer.    Note that you can also Validate the Resource Group before deploying (which I would recommend) errors and success status will be displayed in Visual Studio output window. Now complete the dialog with your azure subscription and the other required information.   Note that you view and edit the parameters before deploying //Image12  Hopefully you will have a successfully deployment of your infrastructure in azure, go check it out… Especially open the WebApp's ApplicationSettings in azure, you should see our greetings key. Dev, Staging and Production So hopefully it all worked fine! Now I want to be able to use the same template for all my environment. Lets starts with copying the WebSite.parameters.jsonrename one to WebSite.parameters-dev.json and the other to WebSite.parameters-prod.json now we can have different parameters depending on what we want to deploy. You might want something better than a S1 for your production WebSite.  If you right click on the project and do another deploy you can now select which parameter file to use. Voilà we have an easy way to set up your azure infrastructure.  For more information see or check out Scott Allen on PluralSight 

Pin It on Pinterest

Share This

Share This

Share this post with your friends!