Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Deploy and manage Azure resources

Quique Martínez edited this page Jun 7, 2016 · 1 revision

Deploy and manage Azure resources

Overview

This tutorial shows how Azure manages resources*.* You will create your own My Azure Resources, which provides an environment for easy deployments by using PowerShell. When you’re finished, Azure Resource Manager will be able to deploy all the resources by using PowerShell.

The following illustration shows the current existing project resources in Azure:

You’ll learn these procedures:

  • How to prepare your computer for Azure development by installing the Azure SDK for .NET.

  • How to set up Visual Studio to help you manage Azure resources.

  • How to create My Azure Resources for the creation of a simple deployment environment.

  • How to publish applications in a simple way after resources are deployed in Azure.

  • How to deploy My Azure Resources by using PowerShell.

Sign up for Microsoft Azure

You need an Azure account to complete this tutorial. You can:

If you want to get started with Azure App Service before you sign up for an Azure account, go to Try App Service. There, you can immediately create a short-lived starter web app in App Service without a credit card or commitments.

Set up the development environment

To start, set up your development environment by installing the latest version of the Azure SDK.

Visual Studio 2015

Visual Studio 2013

If you don't have Visual Studio installed, use the link for Visual Studio 2015, and Visual Studio will be installed along with the SDK for Windows Universal Applications.

Alternatively, depending of the type of target project that will use deployed resources, you might need to install Xamarin Platform, including those platforms that are part of the project, or Visual Studio Tools for Apache Cordova.

For the correct operation of scripts that are created with PowerShell and in case you want to deploy My Azure Resources by using PowerShell, you need to install the extensions, PowerShell Tools for Visual Studio 2015 or PowerShell Tools for Visual Studio 2013.

Azure Resource Manager Tools in Visual Studio Code

The following tutorial shows how to manage Azure resources by using Visual Studio 2015. You can also use Visual Studio Code to manually create resources by using an extension that will integrate into IntelliSense and everything that’s related to Azure resources. As a result, you can easily design the desired template in Visual Studio Code. For more information, see Azure Resource Manager tools.

Create My Azure Resources

The first point to consider before you start to manage Azure resources is the needs of the project. This tutorial will cover the creation of resources that Azure Resource Manager manages for Demos presented in Microsoft Connect(); //2015, specifically ASPNET5 and MobileApp demos. When you finish this tutorial, 10_Demos_Deployment solution will be completed and you’ll have a simple and effective way to deploy the necessary resources to publish services on Azure later.

Create an Azure Resource project

  1. In Visual Studio, go to File > New Project > C# or Visual Studio > Cloud, and choose an Azure Resource Group project.

{width="6.5in" height="4.510416666666667in"}

  1. Because you want to create a custom resource group, you should start with an empty template. Select Blank Template in the list of templates.

{width="6.489583333333333in" height="4.895833333333333in"}

  1. You can see the files that were created in Solution Explorer.

{width="3.40625in" height="3.2708333333333335in"}

  • Deploy-AzureResourceGroup.ps1: A PowerShell script that invokes PowerShell commands to deploy to Azure Resource Manager.

  • Azuredeploy.json: The resource manager template that defines the infrastructure that you want to deploy to Azure and the parameters that you can provide during deployment. It also defines the dependencies between the resources so they are deployed in the correct order.

  • Azuredeploy.parameters.json: A parameters file that contains values that the template needs. These are the values that you pass on to customize each deployment.

  • AzCopy.exe: A tool that’s used by the PowerShell script to copy files from the local storage drop path to the storage account container. This tool is used only if you configure the deployment project to deploy your code along with the template.

Composing the Demo at Microsoft Connect(); //2015

  1. Include the parameters that are required for the template. Open azuredeploy.parameters.json and include the following code as parameters:

  2. Open azuredeploy.json, and the JSON code form deployment template will be deployed. On the left, you see a JSON Outline pane that has the same summary information.

{width="6.489583333333333in" height="3.3541666666666665in"}

You can add and easily modify existing resources in the JSON document from the JSON Outline pane.

{width="2.7604166666666665in" height="1.6875in"}

{width="6.489583333333333in" height="4.895833333333333in"}

  1. Add the following parameters and variables to the template.

  2. Add the following resources to the template with the following information:

    a. App Service Plan (Server Farm) with the name HostingPlan:

    b. A Web App with the name Website and the App Service plan > HostingPlan that you created before. Add an Application Settings for Web Apps with the name connectionstrings that’s associated to this Web App:

    c. A SQL Server with the name SqlServer, and an instance of Azure SQL Database with the name Database that’s associated to this server:

    d. A Web App with the name MobileApp, and the App Service plan > HostingPlan that was created before.

An Application Setting for Web Apps with the name appsettings that’s associated to MobileApp.

An Application Setting for Web Apps with the name connectionstrings that’s associated to MobileApp.

A Nested Deployment with the name Microsoft.Resources/mobile-notificationhub that’s associated with MobileApp.

a. A Nested Deployment with the name NotificationHub with other Nested Deployment with the name [concat(variables('notificationHubNamespace'), '/', variables('notificationHubName'))] that’s associated to the Notification Hub:

  1. Optionally, related Application Insights resources may be included:

Add an Application Insights for Web Apps resource with the name ApplicationInsights, that’s associated with the App Service plan > HostingPlan and the Web App > Website:

  1. You have to organize the resources so that they’re generated in a specific order. Resources should be organized as follows:

{width="5.927083333333333in" height="6.46875in"}

With this, you will have all available resources to generate simple and quick Azure deployments.

You can download the solution.

Deploy My Azure Resources

After you prepare the resources for the deployment, you can deploy them as many times as necessary.

  1. Right click the principal project, and select Deploy > New Deployment.

{width="6.28125in" height="3.75in"}

  1. Sign in to Azure if necessary, and select the desired subscription type. Create a new resource group where all resources that will be created are grouped.

{width="5.145833333333333in" height="4.458333333333333in"}

  1. Optionally, you can click Edit Parameters to modify the deployment parameters.

{width="4.020833333333333in" height="3.40625in"}

The Save passwords option means that the passwords will be saved as plain text in the JSON file. This option is not secure.

  1. Click Deploy to implement the project. The implementation may take several minutes. When it’s finished, you can see the deployed resources in the resource group in the Azure portal.

{width="6.489583333333333in" height="4.958333333333333in"}

Deploy My Azure Resources by using Azure PowerShell

Before you start to work on the solution, you must be signed in.

To sign in your Azure account, use the Login-AzureRmAccount cmdlet.

{width="6.5in" height="1.8020833333333333in"}

You can deploy manually by using PowerShell and have the possibility of creating scripts by using the New-AzureRmResourceGroupDeployment cmdlet*.*

{width="6.5in" height="1.8020833333333333in"}

You specify the resource group and the location of the template. If your template is not local, you could use the -TemplateUri parameter and specify a URI for the template. You can set the -Mode parameter to either Incremental or Complete. Because Resource Manager performs an incremental update during deployment by default, it is not essential to set -Mode when you want Incremental.

If you are familiar with PowerShell, you can cycle through the available parameters for a cmdlet by typing a minus sign (-) and then pressing the TAB key. This same functionality also works with parameters that you define in your template. As soon as you type the template name, the cmdlet fetches the template, parses it, and adds the template parameters to the command dynamically. This makes it very easy to specify the template parameter values. If you forget a required parameter value, PowerShell prompts you for the value.

You can check the Azure portal to see the deployed resources after the implementation is finished.

{width="6.489583333333333in" height="4.958333333333333in"}

Publish your application

After the resources are deployed in Azure, the application will be implemented in a simpler and quicker way.

In this tutorial, the two existing solutions, 01_Demos_ASPNET5 and 06_Demos_MobileApp, will be deployed in the cloud You can download the solutions from the GitHub repository.

01_Demos_ASPNET5

  1. Open the solution with Visual Studio. You can modify the parameters of the default credentials that you need to connect to the private website by modifying the appsettings.json file.

{width="6.5in" height="3.59375in"}

  1. Right-click the MyHealth.Web project, and then click Publish. Select Microsoft Azure App Service as a publish target.

{width="6.489583333333333in" height="5.135416666666667in"}

  1. Select the desired Azure subscription and look for the resource group that you previously deployed and associated to Web Site.

{width="6.489583333333333in" height="4.864583333333333in"}

  1. Click OK. Make sure that you have selected the correct version of DNX (rc1-update1) on the Settings tab.

{width="6.489583333333333in" height="5.135416666666667in"}

  1. Click Publish. The web application will be implemented in Azure. When it’s finished, a web browser with the HealthClinic web site will open.

{width="6.489583333333333in" height="4.260416666666667in"}

06_Demos_MobileApp

  1. Open the solution with Visual Studio.

{width="6.5in" height="3.59375in"}

  1. Right-click the MyHealth.MobileApp project, and then click Publish. Select Microsoft Azure App Service as a publish target.

{width="6.489583333333333in" height="5.135416666666667in"}

  1. Select the desired Azure subscription, and look for the resource group that you previously deployed and associated to Mobile Site.

{width="6.489583333333333in" height="4.864583333333333in"}

  1. Click OK. You can see the different connection parameters on the Connection tab.

{width="6.489583333333333in" height="5.135416666666667in"}

  1. Click Publish. The mobile application starts to implement in Azure. When it’s finished, a browser will indicate that the deployment is finished.

{width="6.5in" height="3.9270833333333335in"}

After both backend services are deployed, you can use the created service URLs in the client applications:

  • In the src\MyHealth.Client.Core\AppSettings.cs file, set the following parameters:

    • ServerUrl to the web service URL.

    • MobileAPIUrl to the mobile service URL.

  • In the src\MyHealth.Client.Cordova\content\app\modulers\shared\services\configService.ts file, set the Azure_API_URL parameter to the mobile service URL.

Other suggested topics to explore