Azure without Azure Portal

Hi. Today I want to show you how to create whole infrastructure for Web Application in Microsoft Azure using Azure Resource Manager in Visual Studio with Azure SDK.

There is no need to use Azure Portal. I will show you also how to deploy application code during infrastructure deployment.

First, create a new ASP.NET Web Application.

For example Web API:

And remove an Authorize attribute from ValuesController ( for further checks).

Next to the same solution add new Azure Resource Group project.

And select blank template.

You should get the following project structure:

Now, open main .json file  and open JSON outline view. You can add new resources there.

First, add a new App Service Plan resource for our application. App Service plan represents the collection of physical resources used to host your apps.

Web Apps, Mobile Apps, Function Apps, and API Apps, in Azure App Service all run in an App Service plan so we need to create one.

 

Then, add Web App resource and select previously added service plan.

Please notice that, the name of Web App which you wrote in form above isn’t the final name of Web Application. In JSON Outline view go to variables section. You should see the following code:

"variables": {
    "ARMWebAppName": "[concat('ARMWebApp', uniqueString(resourceGroup().id))]"},

As you can see Azure wants to add an unique string to your Web App name. Of course you can change it.

If you want to deploy application code during infrastructure deployment add Web Deploy for Web Apps resource and select previously added Web App

After this process your JSON outline view should look like that:

Now, to your Azure Resource Group project add reference to ASP.NET project which you created at start.

It is almost done. Open a Deploy action in Azure Resource Group project.

And create a new resource group:

Final step is parameters edition. Go to Edit Parameters view and fill PackageFolder nad PackageFileName parameters. Fill PackageFolder parameter with a real name of your web application in solution and the PackageFileName parameters with package.zip.

In Deploy to Resource View you should select an proper option for storage account. You can create a new or select existing one.

Storage will contain a web application artifacts for further deployment.

Now everything is done so you can run deployment process.

After few moments insert http://<your-web-app-name>.azurewebsites.net/api/values address in your web browser.

If you will get the following data that means everything works fine.

As you can see with Azure Resource Manager you can fast create Microsoft Azure resources and also deploy application in the same process wihout leaving our beloved Visual Studio IDE.

Leave a Reply

Your email address will not be published. Required fields are marked *