Sunday 26 June 2016

What is ARM & Revolutionizing the cloud deployment

Use Azure cloud ARM Spin up a web application/Sql Server/SQL Database and storage account in azure within 10 seconds  

                Early web developers knows how painful is to set up a web application in IIS and make it work because IIS behaves crazy when your day is bad. Azure has made the life of every web application developer's life so easy by creating the web application in just a few clicks and your website is public and available to internet user, which is not easy in IIS in any sense. And we don’t even have to talk about deploying the web application which has a load balancer. 

                With the Presence of ARM – Azure Resource manager, setting up a Web application, SQL Server, SQL Database and storage manager is only a configuration JSON and which can be created by the visual studio as a template, and deployed using visual studio !

You can spin up a new web application (even VM’s) with any resource (web-app, SQL server etc.) and you can also update the already ARM created resources.

                Let us look out how we can setup a Web application, a SQL Server, SQL Database and azure storage Account in seconds. 

In Visual studio 2015, create a new project and select the azure resource group template.

You need to select the Azure Template with WebApp + Sql from the next window that appear after clicking ok.

Once we click on OK, project is created will have only three files as below.

Three files are 

  • Deploy-AzureResourceGroup.ps1 
  • WebSiteSQLDatabase.json 
  • WebSiteSQLDatabase.parameters.json

We will look in detail about each and every file and see how these files helps us to create azure resources stack in matter of seconds.


This file is used by the visual studio to create the application in azure and it is nothing but a power shell script. It runs the command needed to create the application using the JSON, provided as input. It will be same for any azure resource group project, irrespective of resource you choose to be deployed.


                This files contains the parameter that can be used to configure the resources of the azure, this can be configured to have default values.  (Parameters section of WebSiteSQLDatabase.json file will be configuring the type of parameter used, default values etc.)

Empty Template contains following elements, will look like below.

                This file provides the resources information that needs to be installed in the cloud, it has own variables that can be used declared and used inside the JSON file where we don’t want to repeat the logic for creating a string or any other object that can be reused. For more details about the every element you refer here . We will discuss the template further to understand the resources.

Empty Template contains following elements
   "$schema": "",
   "contentVersion": "",
   "parameters": {  },
   "variables": {  },
   "resources": [  ],
   "outputs": {  }

Every resource will have entry in the resources section and it will have its own configuration detail. For explanatory purpose, we will only look into the web application alone. For more details, look into my code repository in GitHub

Above JSON explains the web app that will be created from the above JSON, you can see the variables are set at runtime based on the parameter value, which can be altered by us in the configuration. 

The current template from the visual studio has only WebApp+SQL, when we need to add one more resource, in our case it is storage manager, we need to add through the another cool feature in Visual studio called as JSON Outline

You can open this window from other window in view menu. Open the WebsiteSQLDatabase.JSON before opening the JSON Outline. 

You can add the storage account by right clicking the resources in the JSON Outline and selecting ‘Add new resource’.  Select the Storage account and name it. 

Once we click add the below JSON will be added to the WebSiteSQLDatabase.JSON. Make sure you provide the name of the storage account in lower case letter.

You are all set with the configurations to create a web application, an SQL Server, an SQL Database and Azure Storage Account. Will not take more than 2 minutes to create a solution with these configuration using visual studio. 

You can also get lots of pre-existing template that is already available in GitHub. You can download any template or refer them to create more resource such as redis cache, mongo db, spin up a new Linux virtual machine. 

You can now deploy the ARM to azure to create the specified resources. 

You will see the deploy to resource group window where we can Edit Parameters that can be configured for our ARM, which can also be saved to the WebSiteSQLDatabase.parameters.json

Once you click on the deploy button, you need to watch the output window because the visual studio does everything at the background while running Power-Shell script.


  You can see after couple of minutes when you login into azure you can see the new resource group that was created as all the specified resources created automatically

ARM helps to create scripts to automate the resource creation process in azure cloud so we can do automate testing, add new web application to the new client it can also deploy the code automatically to the cloud. You should really try this in azure since it is the coolest feature in azure.


Tuesday 7 June 2016

Understand SSL and Implement in Azure Website

What is http?

     Http means hypertext transfer protocol which is present in application layer of the network which is used to exchange or transfer hypertext. For more read here

What is https?

  Https is nothing but hypertext transfer protocol Secure, this can be achieved by implementing the SSL in your application.

Https Vs SSL 

  Http is a protocol in application layer and SSL is nothing but Secure sockets Layer, implemented in transport layer. SSL implements secured bi-directional tunnel for two hosts to communicate. So when SSL is implemented in our website, the http can communicate in the tunnel created by the SSL.

How to get SSL

SSL can be bought online and there are many companies provide SSL like comodo, verisign, trustsign etc. You can learn more about buy SSL @ You also get free ssl from StartSSL

Let us look into the example on how to implement SSL in your azure website.  Considering you have already bought the SSL using any one of the vendor. We used trustsign in our organisation for buying ssl certificate. 

Let us consider the url of the azure web application be and we need to implement the ssl for this application. But we might not use the same azure url for the enduser, so it will be an customized domain url and we can call it as

Note:  By Default, all *. can be accessed using https and also http. SSL is implemented by default.

You need to add the cname in your domain registrar and also add your azure url. 

Then go to your azure portal to add the CName url created with domain registrar. 

Go to Configure tab and navigate to “Manage domain” and then click it.

Once this is setup you can access using URL. Test it in your browser.

You need pfx key to configure your web app to https compatible in azure and assign the ssl bindings.

You need below keys provided by your SSL provider to create pfx file.

1.       Private Key generally .key extension
2.       Certificate (public key) generally in cer extension
3.       Intermediate certificate Key – generally in PEM Extension
4.       Password used to encrypt the pfx file that will be created

Note: above all keys can also be present in a file with txt extension. File can be of any name or extension it does not matter. 

Now you need to create pfx file using OpenSSL You can download the setup for Openssl.exe here  

Now run the below command to create the pfx file. You need to open your command prompt and paste the altered command as per your information.

Above command will create the pfx file in the same folder unless specified otherwise, with following message

Then navigate back to azure portal.

Click on Upload certificate and upload the pfx file created. Enter the password used while creating the pfx file

Now you can see the ssl certificate in the ssl bindings, populated as dropdown data, select them and save your azure web app.

Once your application changes are saved you can navigate to the app using the https url , https:// and test them.

Note: Now your web application can accept both http and https request, if you want to limit your application to https only then you need to change in web.config. 



Add below code in <System.webserver>

    <rewrite xdt:Transform="Insert">
        <rule name="Force HTTPS" enabled="true">
          <match url="(.*)" ignoreCase="false" />
            <add input="{HTTPS}" pattern="off" />
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />

Above configuration will redirect any http request with 301 http code to https url. Above example is for .net based azure web application, for other servers such as apache/NodeJS visit here

You can start testing the Https in the browser make sure you see a green lock symbol to check https implementation is fine.

Post SSL Implementation Issues

  • Mostly the issues I faced after converting my http application to https application is mixed content error,where we have used any external reference url in our web app,  that is pointing to http link(Check script/link tag), you need to change them to https link in your application.

Build Bot using LUIS