azure Archives - Learn Smart Coding https://blogs.learnsmartcoding.com/tag/azure/ Everyone can code! Sat, 27 Nov 2021 14:52:43 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.2 209870635 Provision virtual machines using ARM Templates | Implement IaaS solutions | Part 4 https://blogs.learnsmartcoding.com/2021/11/27/provision-virtual-machines-using-arm-templates-implement-iaas-solutions-part-4/ https://blogs.learnsmartcoding.com/2021/11/27/provision-virtual-machines-using-arm-templates-implement-iaas-solutions-part-4/#respond Sat, 27 Nov 2021 14:52:43 +0000 https://karthiktechblog.com/?p=923 This post covers how to provision virtual machines using ARM Templates that is part 4 of Implement Iaas Solutions. We have been learning how to provision virtual machines using various methods like Azure Portal, CLI, Powershell. Let’s learn about ARM Templates. An ARM template is a JSON‑formatted file that is a configuration document that defines […]

The post Provision virtual machines using ARM Templates | Implement IaaS solutions | Part 4 appeared first on Learn Smart Coding.

]]>
This post covers how to provision virtual machines using ARM Templates that is part 4 of Implement Iaas Solutions. We have been learning how to provision virtual machines using various methods like Azure Portal, CLI, Powershell. Let’s learn about ARM Templates.

An ARM template is a JSON‑formatted file that is a configuration document that defines what resources you want to be deployed in Azure with their configurations. You can create any resource with an ARM template.

Provision virtual machines using ARM Templates | Implement IaaS solutions | Part 4

Understanding ARM Templates

I will be focusing on Virtual Machine in this ARM Template topic. ARM templates are a building block for deployment automation. Using ARM templates, you can parameterize the configuration elements for resources defined in an ARM template.

You can use parameters for commonly changed configuration elements such as virtual machine names and many more. Other elements are image names, network security, storage account name, and many more.

After that, you can then use that same ARM template repeatedly to deploy the environment defined in the template. However, use different parameters to customize each environment at deployment time.

For example, you can have each set of parameters for Dev, QA, Stage, and one for Production that will provide consistency to your deployments. 

How ARM Template works?

 You create an ARM template and then an ARM template is submitted to Azure Resource Manager for deployment. The tools used are Azure CLI, Powershell, Azure Portal.

Once the ARM Template is deployed, it reads the details inside the ARM Template like creating resources, depleting resources modifying existing properties or creating new properties.

Creating ARM Templates

  1. You can build and export an ARM template from the Azure portal.
  2. Write your own manually.
  3. Also, you can start from the Quickstart library, which is a collection of community templates available in the Azure portal in the Custom deployment blade.

In order to focus on the higher-level process of how ARM templates work, we will mainly cover the building and exporting of an ARM template in the Azure portal.

How it works?

After you deploy an ARM template, Resource Manager receives that template, formatted as JSON, and then converts the template into REST API operations. This means you can use ARM Templates using many tools that include Azure Portal, CLI, Powershell.

ARM Template Structure

Let’s go through the structure of the ARM Template.

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
	"apiProfile":"",
    "parameters": { },
    "variables": {},
	"functions": [],
    "resources": [],
    "outputs": {}
}

First, we have some header information. Schema is the location of the JSON schema file that describes the template’s language.

Content version is the version of the template, which is defined by you so that you can version control your templates.

apiProfile, which allows for versioning of the resource types that are defined in the template.

Parameters, which are used to provide values during deployment so that the same template can be reused for multiple deployments. This is where you’ll define deployment‑specific configuration parameters, and this is very useful when you want to be able to use that same template over and over again, but change out the parameters for specific deployments. Common parameters are resource groups, regions, resource names, and network configurations.

Variables define values that are reused in your templates and are often constructed from parameter values.

Functions allow you to create customized functions that simplify your templates and help enable reuse of templates. A common use for functions is generating a resource name based on the environment that it’s being deployed into.
To create your own functions, see User-defined functions.

The commonly used function is concat which combines multiple string values and returns the concatenated string, or combines multiple arrays and returns the concatenated array.

Example

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "prefix": {
      "type": "string",
      "defaultValue": "prefix"
    }
  },
  "resources": [],
  "outputs": {
    "concatOutput": {
      "type": "string",
      "value": "[concat(parameters('prefix'), '-', uniqueString(resourceGroup().id))]"
    }
  }
}

for more information read it from string functions

DEMO

It is time for the demo, to get started we will log in to Azure Portal and create an ARM Template. Follow the instructions in detail of how to Provision virtual machines using the Azure portal | Implement IaaS solutions | Part 1

Once you are on the final page as shown in the image below.

Provision virtual machines using ARM Templates

Instead of clicking on create which we normally do, we will click on “Download a template for automation” to view the template. This creates the template and parameters JSON files needed for an ARM template‑based deployment for the virtual machine that we just configured.

From this screen at the top, we can click Download to download the template and parameters files, we can click Add to add them to a library for further deployments inside of Azure, or we can deploy them right from here.

Examining an ARM Template

Examining an ARM Template

In this template, we can see that we have three sections defined, Parameters, Variables, and Resources. It is important to note that not all the sections are mandated to fill, many are optional. If we don’t provide them, the default values will be taken.

In this template, we have 19 different parameters defined, 3 variables, and 5 resources.

Parameter section | ARM Template

The template starts with parameters, you can see that these are the parameters used to provide values for unique deployments allowing us to change them at runtime. In this section of a template, it’s just the declaration of the parameters. The actual parameters of values for this particular deployment are going to be in the parameters file.

Some of the exposed parameters in this template are location, networkInterfaceName, enableAcceleratedNetworking, networkSecurityGroupName, virtualNetworkName, networkSecurityGroupRules, and so on.

A collection of parameters are exposed in this template. The values are going to come from the parameters.json file. clicking on the parameter tab will present you with the following parameter values.

arm template parameter values

All the sections that we filled in the Azure portal to create a virtual machine are included in the parameter values.

Decoupling these values from the template allows us to use that template file over and over again, setting unique values for each deployment in this parameters file.

Variables section | ARM Template

Variables are used to define values for reuse in a template. And there are three variables in this template, we will look into those.

The first variable is nsgId. A system function being used, resourceId. This will return the resource ID of a defined resource. The value that is returned from that function is stored in the variable nsgId.

nsgId is reused within the ARM template so frequently.

Provision virtual machines using ARM Templates

We then see the virtual network name as the second variable that was passed in via a parameter. And then for the final variable, we see subnetRef. It’s going to use another system function, concat, to concatenate together the values of the vnetId variable, the string subnets, and a template parameter named subnetName. That’s going to combine those strings all together to set the value for subnetRef.

Resources section | ARM Template

The last part is resources. There are 5 resources defined in this template. These are the actual resources being deployed in Azure by this ARM template.

In the resources section, we have an important section called the dependsOn section, which is a list of resources that this resource depends on before it gets deployed. And so this is a way for us to define some ordering and how resources in this template are created. This network interface won’t be created until these three other resources defined are deployed.

Similarly, all the other sections are defined in this way and the ARM template will deploy the dependent resources first before any other resources are deployed.

Deploying ARM Template

Provision virtual machines using ARM Templates | Implement IaaS solutions | Part 4

This downloads a zip file containing parameter.json and template.json files. If I wanted to deploy this template as is, I can click Deploy and that will take me to the custom deployment page to start a deployment. Clicking Deploy, you can see that it has prepopulated the parameters that we entered when we created the ARM template.

Deploy a custom template

Let me show you how to build this template from scratch. In the search box, search with “Deploy a custom template” and choosing this will present a screen to get started with our own template.

Provision virtual machines using ARM Templates | Implement IaaS solutions | Part 4

You need to provide an Admin password that was not in the downloaded template. You can edit the parameter file and update the admin password there or provide it in the Azure portal.

Now, it’s a regular step to click on create a virtual machine.

Deploying ARM Template using Powershell

#Let's login, may launch a browser to authenticate the session.
Connect-AzAccount -SubscriptionName 'Demo Account'


#Ensure you're pointed at your correct subscription
Set-AzContext -SubscriptionName 'Demo Account'


#If you resources already exist, you can use this to remove the resource group
Remove-AzResourceGroup -Name 'lscdemo-rg'


#Recreate the Resource Group
New-AzResourceGroup -Name 'lscdemo-rg' -Location 'EastUS'


#We can deploy ARM Templates using the Portal, Azure CLI or PowerShell
#Make sure to set the adminPassword parameter in parameters.json around line 80 "adminPassword" prior to deployment.
#Once finished, look for ProvisioningState Succeeded.
New-AzResourceGroupDeployment `
    -Name mydeployment -ResourceGroupName 'lscdemo-rg' `
    -TemplateFile './template/template.json' `
    -TemplateParameterFile './template/parameters.json' 

Using this template we can now deploy the virtual machine in Azure.

Clean up resource

Now the Demo is complete for creating a virtual machine. It is time to clean up the resources we used.

When no longer needed, you can delete the resource group, virtual machine, and all related resources.

Go to the resource group for the virtual machine, then select Delete resource group. Confirm the name of the resource group to finish deleting the resources.

Related resources

Conclusion

In this post, I have covered the topic of the Provision of virtual machines using ARM Templates. This is part of implementing IaaS solutions, part 4. Happy learning!.

The post Provision virtual machines using ARM Templates | Implement IaaS solutions | Part 4 appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2021/11/27/provision-virtual-machines-using-arm-templates-implement-iaas-solutions-part-4/feed/ 0 923
Provision virtual machines using Azure CLI | Implement IaaS solutions | Part 2 https://blogs.learnsmartcoding.com/2021/11/02/provision-virtual-machines-using-azure-cli-implement-iaas-solutions-part-2/ https://blogs.learnsmartcoding.com/2021/11/02/provision-virtual-machines-using-azure-cli-implement-iaas-solutions-part-2/#respond Tue, 02 Nov 2021 19:10:35 +0000 https://karthiktechblog.com/?p=860 Introduction This post covers how to Provision virtual machines using Azure CLI. This is part of implementing the IaaS solutions topic. This is a continuation of the previous post Provision virtual machines using the Azure portal. This module’s topics are part of implementing IaaS solutions and I will cover “Provision Virtual Machine”. Provision virtual machines […]

The post Provision virtual machines using Azure CLI | Implement IaaS solutions | Part 2 appeared first on Learn Smart Coding.

]]>
Introduction

This post covers how to Provision virtual machines using Azure CLI. This is part of implementing the IaaS solutions topic. This is a continuation of the previous post Provision virtual machines using the Azure portal.

This module’s topics are part of implementing IaaS solutions and I will cover “Provision Virtual Machine”.

provision windows and linux virtual machine

Provision virtual machines using Azure CLI

In order to work with Azure CLI, first, we should download the Azure CLI and install it. I have a windows machine so I choose to download CLI for windows.

Install Azure CLI on Windows

The Azure CLI is available to install in Windows, macOS, and Linux environments. It can also be run in a Docker container and Azure Cloud Shell. View complete details here

Now, I have installed Azure CLI. Let’s get started with its usage.

How to use CLI

After CLI installation, you can use the windows command prompt or PowerShell.

I have used PowerShell for the demo.

Open PowerShell for CLI

Click on start or windows key => type “powershell” => open Windows PowerShell

On the PowerShell window, enter the script as below and log in interactively. Login interactively meaning, a browser will open and you need to sign in to Azure Portal with your Azure portal credentials.

az login

az stands for azure and will be recognized once Azure CLI is installed in your machine.

Provision virtual machines using Azure CLI

Azure CLI commands to provision windows virtual machines

There are a lot many az vm commands. the below commands are used to create a VM with minimum required configurations. to check the full command list check az vm commands.

#Login interactively and set a subscription to be the current active subscription. My subscription name is "Demo Account", chnage to your subscription name

az login
az account set --subscription "Demo Account"


#Create a Windows VM.

#check existing group listed in table format 
az group list --output table 


#Create a resource group.
az group create --name "LSCDemo-rg" --location "eastus"


#Creating a Windows Virtual Machine (for image, choose any avilable name)
az vm create 
    --resource-group "LSCDemo-rg" 
    --name "LSCDemo-win-cli" 
    --image "win2019datacenter" 
    --admin-username "demoadmin" 
    --admin-password "jsfdhsd$$Ddd$%^&*" 


#Open RDP for remote access, it may already be open
az vm open-port 
    --resource-group "LSCDemo-rg" 
    --name "LSCDemo-win-cli" 
    --port "3389"


#Get the IP Addresses for Remote Access
az vm list-ip-addresses 
    --resource-group "LSCDemo-rg" 
    --name "LSCDemo-win-cli" 
    --output table

Provision virtual machine using Azure CLI | Implement IaaS solutions | Part 2

Verify and Log into the Windows VM via RDP

This topic is already covered in my previous post, if you haven’t read the post, check here Provision virtual machines using the Azure portal | Implement IaaS solutions | Part 1

Azure CLI commands to provision linux virtual machines

Creating Linux virtual machines is almost the same as creating a Windows VM. There are only a few changes and the authentication mechanism needs to be changed. Let’s dive in and learn.

The authentication mechanism used for Linux is SSH. First, we need to generate a public/private RSA key pair, to do so you can use “ssh-keygen” available in your machine.

Steps

  1. Type “ssh-keygen” in run command. This opens up a terminal.
  2. “Enter file in which to save the key (C:\Users\karth/.ssh/id_rsa):” for this promt, leave it. Just press enter. This action will create a folder under current user name.
  3. Enter passphare. enter a password here and then enter again when asked.
  4. That’s it, the file is created.
ssh-keygen for rsa key
ssh-keygen to generate RSA key for Linux
#Creating a Linux Virtual Machine
az vm create 
    --resource-group "LSCDemo-rg" 
    --name "LSCDemo-linux-cli" 
    --image "UbuntuLTS" 
    --admin-username "demoadmin" 
    --authentication-type "ssh" 
    --ssh-key-value ~/.ssh/id_rsa.pub 


#OpenSSH for remote access, it may already be open
az vm open-port 
    --resource-group "LSCDemo-rg" 
    --name "LSCDemo-linux-cli" 
    --port "22"



#Get the IP address for Remote Access
az vm list-ip-addresses 
    --resource-group "LSCDemo-rg" 
    --name "LSCDemo-linux-cli" 
    --output table


#Log into the Linux VM over SSH (paste the ip from above command, see image)
ssh demoadmin@PASTE_PUBLIC_IP_HERE

Provision virtual machines using Azure CLI

Connect to Linux VM

Once you attempt to connect to the VM, it will prompt for the passphrase that was used to create ssh file. Provide the same passphrase to connect to VM.

Provision virtual machine using Azure CLI | Implement IaaS solutions | Part 2

Video tutorial

Clean up resource

Now the Demo is complete for creating a virtual machine. It is time to clean up the resources we used.

When no longer needed, you can delete the resource group, virtual machine, and all related resources.

Go to the resource group for the virtual machine, then select Delete resource group. Confirm the name of the resource group to finish deleting the resources.

Related resources

Conclusion

In this post, I have covered the topic of the Provision of virtual machines using Azure CLI that is part of implementing IaaS solutions. This post covers CLI commands for creating both Windows and Linux VM. Other parts of this exam are covered in other posts. Happy learning!.

The post Provision virtual machines using Azure CLI | Implement IaaS solutions | Part 2 appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2021/11/02/provision-virtual-machines-using-azure-cli-implement-iaas-solutions-part-2/feed/ 0 860
Provision virtual machines using the Azure portal | Implement IaaS solutions | Part 1 https://blogs.learnsmartcoding.com/2021/11/02/provision-virtual-machines-using-the-azure-portal-implement-iaas-solutions-part-1/ https://blogs.learnsmartcoding.com/2021/11/02/provision-virtual-machines-using-the-azure-portal-implement-iaas-solutions-part-1/#respond Tue, 02 Nov 2021 13:07:23 +0000 https://karthiktechblog.com/?p=840 Introduction As part of Azure AZ-204 certification, this post will cover Provision virtual machines using the Azure portal that are part of Implement IaaS solutions. This module’s topics are part of implementing IaaS solutions and I will cover “Provision Virtual Machine”. What is infrastructure as a service (IaaS)? This is the foundational category of cloud […]

The post Provision virtual machines using the Azure portal | Implement IaaS solutions | Part 1 appeared first on Learn Smart Coding.

]]>
Introduction

As part of Azure AZ-204 certification, this post will cover Provision virtual machines using the Azure portal that are part of Implement IaaS solutions.

This module’s topics are part of implementing IaaS solutions and I will cover “Provision Virtual Machine”.

Provision virtual machines VM | Implement IaaS solutions

What is infrastructure as a service (IaaS)?

This is the foundational category of cloud computing services. With IaaS, you rent IT infrastructure—servers and virtual machines (VMs), storage, networks, and operating systems. You can use cloud providers such as Microsoft Azure on a pay-as-you-go basis.

What is Virtual Machine VM ?

A virtual machine, commonly shortened to just VM, is no different than any other physical computer like a laptop, smartphone, or server.

It has a CPU, memory, disks to store your files, and can connect to the internet if needed. While the parts that make up your computer (called hardware) are physical and tangible.

VMs are often thought of as virtual computers or software-defined computers within physical servers, existing only as code.

Virtual Machines used for the following

Building and deploying apps to the cloud

Trying out a new operating system (OS), including beta releases.

Backing up your existing OS

Spinning up a new environment to make it simpler and quicker for developers to run dev-test scenarios.

Accessing virus-infected data or running an old application by installing an older OS.

Running software or apps on operating systems that they weren’t originally intended for.

From Microsoft

Methods of Provision virtual machines VM.

Four ways you could create VM, Azure Portal, Azure CLI, Azure PowerShell, and Azure ARM Templates.

Video tutorial

Provision virtual machines VM using portal

Create Windows virtual machines in Azure

Azure VMs are an on-demand scalable cloud-computing resource. You can start and stop virtual machines anytime, and manage them from the Azure portal or with the Azure CLI.

You can also use a Remote Desktop Protocol (RDP) client to connect directly to the Windows desktop user interface (UI) and use the VM as if you were signed in to a local Windows computer.

Steps

Sign in to the Azure portal. If you do not have an account, don’t worry it is free to start with. Check out below for details.

Getting started with Azure
  • On the Azure portal, under Azure services, select Create a resource. The Create a resource pane appears.
  • In search services search box, search for “virtual” as you will see “Virtual machine”, click on it.
  • In the Basics tab, under Project details, make sure the correct subscription is selected and then choose to Create new resource group.
  • Choose an existing resource group or create a new one. I have named my new resource group as “LSCDemo-VM”.
  • Fill up the instance details as per the screenshot below. Here we have named “LSCVMDemo” as VM name and selected the region for our VM deployment.
  • pick up an image from the drop down, I picked “windows server 2016 datacenter” with standard power for this demo.
  • Chose a size of the VM as per the need.
Provision virtual machines using the Azure portal | Implement IaaS solutions  | Part 1
  • Provide Administarator account details like username and password.
  • Under Inbound port rules, choose Allow selected ports and then select RDP (3389) and HTTP (80) from the drop-down.
  • Leave the remaining defaults and then select the Review + create button at the bottom of the page.
  • After validation runs, select the Create button at the bottom of the page.
  • After deployment is complete, select Go to resource. Here you can see all the details of the newly created VM.
Provision virtual machines using the Azure portal RDP configuration

Deployment of VM completed.

Connect to virtual machine

VM dashboard

On the resource dashboard page, all the details of the virtual machine appear. select the Connect button then select RDP

Click on download RDP and open it. Depending on your machine be it MAC or Windows, the appropriate RDP file will be downloaded,

connect VM using RDP

Log into VM using username and password.

server configuration

Installation of web server in VM

Open a PowerShell prompt on the VM and run the following command:

Install-WindowsFeature -name Web-Server -IncludeManagementTools

To open PowerShell in windows, click on the start or run command, type “Powershell”. This will open the PowerShell window.

Installation of web server in VM

The webserver is now installed. To open Internet Information Service (IIS), go to Tools => Internet Information Service (IIS).

Now, we can deploy the applications to IIS.

Installation of web server in VM  open IIS

Clean up resource

Now the Demo is complete for creating a virtual machine. It is time to clean up the resources we used.

When no longer needed, you can delete the resource group, virtual machine, and all related resources.

Go to the resource group for the virtual machine, then select Delete resource group. Confirm the name of the resource group to finish deleting the resources.

Related resources

Resources

1. MSDN: Quickstart: Create a Windows virtual machine in the Azure portal

2. AZ-204 Developing Solutions for Microsoft Azure

Conclusion

In this post, I have covered the topic of the Provision of virtual machines using the Azure portal that is part of implementing IaaS solutions. Other parts of this exam are covered in other posts. Happy learning!.

The post Provision virtual machines using the Azure portal | Implement IaaS solutions | Part 1 appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2021/11/02/provision-virtual-machines-using-the-azure-portal-implement-iaas-solutions-part-1/feed/ 0 840
AZ-204 Developing Solutions for Microsoft Azure https://blogs.learnsmartcoding.com/2021/10/29/az-204-developing-solutions-for-microsoft-azure/ https://blogs.learnsmartcoding.com/2021/10/29/az-204-developing-solutions-for-microsoft-azure/#respond Fri, 29 Oct 2021 21:35:50 +0000 https://karthiktechblog.com/?p=834 Introduction In this post, I will provide guidance on preparing Exam AZ-204 Developing Solutions for Microsoft Azure. Preparing for certification is a crucial activity for any IT or development professional Learn new skills to boost your productivity. Earn certifications that show you are keeping pace with today’s technical roles and requirements. In this guide, you […]

The post AZ-204 Developing Solutions for Microsoft Azure appeared first on Learn Smart Coding.

]]>
Introduction

In this post, I will provide guidance on preparing Exam AZ-204 Developing Solutions for Microsoft Azure.

Preparing for certification is a crucial activity for any IT or development professional

Learn new skills to boost your productivity. Earn certifications that show you are keeping pace with today’s technical roles and requirements.

In this guide, you will learn everything you need to know to help you prepare for the Certified Azure Developer Associate certification.

The content of this exam was updated on March 26, 2021. Please download the skills measured document for more information.

Whom Exam AZ-204 certification is for ?

Microsoft is now going in the direction of career-focused certifications rather than certifications for specific technologies.

The Certified Azure Developer Associate (AZ-204) certification is for someone who wants to become or is a developer.

The core technologies used are Azure SDKs, serverless, containerization, security, and automation. Instead of focusing solely on a piece of technology, the certification is focused on the tools that will help you either fill in the Azure developer gaps or learn to become a developer in Azure.

AZ-204 Developing Solutions for Microsoft Azure

Getting Started

Azure getting started - AZ-204 Developing Solutions for Microsoft Azure

AZ-204 Developing Solutions for Microsoft Azure Skills Measured

  • Develop Azure compute solutions (25-30%)
  • Develop for Azure storage (15-20%)
  • Implement Azure security (20-25%)
  • Monitor, troubleshoot, and optimize Azure solutions (15-20%)
  • Connect to and consume Azure services and third-party services (15-20%)

I have covered each of the topics under the above sections in detail. You will get to read about the step by step tutorial and also real-time lab exercise on my Youtube channel

Develop Azure compute solutions (25-30%)


Implement IaaS solutions


Create Azure App Service Web Apps

  • create an Azure App Service Web App
  • enable diagnostics logging
  • deploy code to a web app
  • configure web app settings including SSL, API settings, and connection strings
  • implement autoscaling rules including scheduled autoscaling and autoscaling by operational or system metrics


Implement Azure functions

  • create and deploy Azure Functions apps
  • implement input and output bindings for a function
  • function triggers by using data operations, timers, and webhooks
  • implementing Azure Durable Functions
  • implementation of custom handlers

Develop for Azure storage (15-20%)

Develop solutions that use Cosmos DB storage

  • select the appropriate API and SDK for a solution
  • implement partitioning schemes and partition keys
  • perform operations on data and Cosmos DB containers
  • set the appropriate consistency level for operations
  • manage change feed notifications

Develop solutions that use blob storage

  • move items in Blob storage between storage accounts or containers
  • set and retrieve properties and metadata
  • perform operations on data by using the appropriate SDK
  • implementing storage policies, and data archiving and retention

Implement Azure security (20-25%)

Implementing user authentication and authorization

  • authenticate and authorize users by using the Microsoft Identity platform
  • authenticate and authorize users and apps by using Azure Active Directory
  • create and implement shared access signatures

Implement secure cloud solutions

  • secure app configuration data by using App Configuration Azure Key Vault
  • develop code that uses keys, secrets, and certificates stored in Azure Key Vault
  • implement Managed Identities for Azure resources
  • implement solutions that interact with Microsoft Graph

Monitor, troubleshoot, and optimize Azure solutions (15-20%)

Integrate caching and content delivery within solutions

  • configure cache and expiration policies for Azure Redis Cache
  • implement secure and optimized application cache patterns including data sizing, connections, encryption, and expiration

Instrument solutions to support monitoring and logging

  • configure an app or service to use Application Insights
  • analyze and troubleshoot solutions by using Azure Monitor
  • implement Application Insights web tests and alerts

Connect to and consume Azure services and third-party services (15-20%)

Implement API Management

  • create an APIM instance
  • configure authentication for APIs
  • define policies for APIs

Develop event-based solutions

  • implement solutions that use Azure Event Grid
  • implement solutions that use Azure Event Hubs

Develop message-based solutions

  • implement solutions that use Azure Service Bus
  • implement solutions that use Azure Queue Storage queues

For each of these topics, the study link will be provided, and video tutorials.

Conclusion

The Certified Azure Developer Associate (AZ-204) certification is for someone who wants to become or is a developer. Not everyone learns the same way. Some read book cover to cover, some watch videos, some practice more in the lab. Whatever the path is, this guide can help you finish this certification. You can do this if you work hard. All the best, happy coding!.

The post AZ-204 Developing Solutions for Microsoft Azure appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2021/10/29/az-204-developing-solutions-for-microsoft-azure/feed/ 0 834
How to: Create API documentation using OpenAPI & Swagger https://blogs.learnsmartcoding.com/2020/01/10/how-to-create-api-documentation-using-openapi-and-swagger/ https://blogs.learnsmartcoding.com/2020/01/10/how-to-create-api-documentation-using-openapi-and-swagger/#respond Fri, 10 Jan 2020 10:45:36 +0000 https://karthiktechblog.com/?p=301 Introduction In this post, I show how to create API documentation using OpenAPI & Swagger. This post will help to cover a part of knowledge required to complete Azure AZ-203 certification. To start with Azure AZ-203 certification, take a look at my post EXAM AZ-203: DEVELOPING SOLUTIONS FOR MICROSOFT AZURE What is API documentation ? […]

The post How to: Create API documentation using OpenAPI & Swagger appeared first on Learn Smart Coding.

]]>
Introduction

In this post, I show how to create API documentation using OpenAPI & Swagger. This post will help to cover a part of knowledge required to complete Azure AZ-203 certification.

To start with Azure AZ-203 certification, take a look at my post EXAM AZ-203: DEVELOPING SOLUTIONS FOR MICROSOFT AZURE

What is API documentation ?

API documentation is the information that is required to successfully consume and integrate with an API. This can be in the form of technical writing, code samples and examples for better understanding how to consume an API.

API Documentation using OpenAPI & Swagger

When consuming a Web API, understanding its various methods can be challenging for a developer who is new to consume our API.

Swagger, also known as OpenAPI, solves the problem of generating useful documentation and help pages for Web APIs.

In this post, Swashbuckle.AspNetCore is shown with a demo app.

Swashbuckle.AspNetCore is an open source project for generating Swagger documents for ASP.NET Core Web APIs.

Additional Resource For Swagger

Swagger

Background of Demo App

I created an demo App with N-Tier architecture that uses Azure SQL database as back end database. Demo app has a controller called Product which does CURD functionality.

The full demo application is available for free and you may download from my GitHub repository.

To download this demo related code, pick branch code “feature/ImplementCURDFunctionality”

Get Started

In this demo app, I will be using my existing asp.net core API app and add code to start showing API documentation using Swagger’s OpenAPI

Setup and Configure OpenAPI & Swagger

Step 1

Install nuget package Swashbuckle.AspNetCore. and some minimum setup to start showing API documentation automatically.

Step 2

Add Swagger configuration to the ConfigureServices method from the Startup class.

services.AddSwaggerGen(
                options =>
                {
                    var assembly = typeof(Startup).Assembly;
                    var assemblyProduct = assembly.GetCustomAttribute().Product;

                    options.DescribeAllEnumsAsStrings();
                    options.DescribeAllParametersInCamelCase();
                    options.DescribeStringEnumsInCamelCase();

                    var info = new Info
                    {
                        Version = "v1",
                        Title = "KarthikTechBlog:Shopping - V1",
                        TermsOfService = "None",
                        Contact = new Contact()
                        {
                            Name = "Karthik",
                            Email = "karthiktechblog.com@gmail.com",
                            Url = "http://www.karthiktechblog.com"
                        }
                    };

                    options.SwaggerDoc("v1", info);

                    // Set the comments path for the Swagger JSON and UI.
                    var basePath = PlatformServices.Default.Application.ApplicationBasePath;
                    var xmlPath = Path.Combine(basePath, "KarthikTechBlog.xml");
                    options.IncludeXmlComments(xmlPath);

                    options.CustomSchemaIds(x => x.FullName);
            }
            );

Step 3

Next is to add Swagger in the request pipeline.

// Enable middleware to serve generated Swagger as a JSON endpoint
            app.UseSwagger();

            // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "API V1");
            });

Step 4

Add required attributes to the controller action methods to show in API documentation. Adding ProducesResponseType attribute to the method help determines what is expected from API endpoint.

[HttpGet("")]
[ProducesResponseType(typeof(IReadOnlyList), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ModelStateDictionary), StatusCodes.Status404NotFound)]
public async Task GetProducts()
{
	var products = await ProductService.GetProductsAsync();

	var model = Mapper.Map>(products);
	return new OkObjectResult(model);
}

To read more, visit how to implement create, read, update, and delete functionalities using Entity Framework Core

Create API documentation using OpenAPI & Swagger
Create API documentation using OpenAPI & Swagger

Conclusion

In this post, I showed how to create API documentation using OpenAPI & Swagger. This post is part of learning track for azure AZ-203 certification.

That’s all from this post. If you have any questions or just want to chat with me, feel free to leave a comment below.

The post How to: Create API documentation using OpenAPI & Swagger appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2020/01/10/how-to-create-api-documentation-using-openapi-and-swagger/feed/ 0 301
How to: Create an Azure App Service API app https://blogs.learnsmartcoding.com/2020/01/07/how-to-create-an-azure-app-service-api-app-for-free/ https://blogs.learnsmartcoding.com/2020/01/07/how-to-create-an-azure-app-service-api-app-for-free/#comments Tue, 07 Jan 2020 21:41:29 +0000 https://karthiktechblog.com/?p=290 Introduction In this short post, I’m going to cover topic “create an Azure App Service API app”. The details in this post will help to cover a part of knowledge required to complete Azure AZ-203 certification. Getting Started To publish any Web or API application that may have been developed using any programming language, we […]

The post How to: Create an Azure App Service API app appeared first on Learn Smart Coding.

]]>
Introduction

In this short post, I’m going to cover topic “create an Azure App Service API app”. The details in this post will help to cover a part of knowledge required to complete Azure AZ-203 certification.

Getting Started

To publish any Web or API application that may have been developed using any programming language, we need a place to host. “Azure App Service API app” comes handy for such case.

Yes, it is easy to create and publish API app in few minutes with Azure portal.

Take a look at my post how to create an Azure App Service Web App

Create Azure App Service API App

This is almost identical to my previous post on how to create an Azure App Service Web App.

Currently all of Web, Mobile and API Apps are collectively called App Services.

Azure still offer customer to be able to create a Mobile App and a Web App in the gallery but that is basically resolve into an App Service App.

There are two topics under ” Create Azure App Service API apps ” and they are as below. We will cover the first part in this post.

  • create an Azure App Service API app
  • create documentation for the API by using open source and other tools

To create API App, simply go to the search bar in the top and search with “API App” keyword. Search results that looks like below image.

Click on API App to begin deployment.

Create an Azure App Service API app

It is relatively simple to create and get this app deployed in few minutes using azure portal.

Follow the steps below

How to: Create an Azure App Service API app

Step by step guide to create API App

  1. Provide a unique name for the API App.
  2. Choose a subscription you have. E.g. If you have created a free account, you will see “Free trial” as subscription. I have Pay as you go plan so I have chosen that.
  3. Choose a resource group or create one. This helps to group various resource together.
  4. Choose an App service plan, I have selected existing one which is a Free tier F1. Refer this post for more details
  5. Leave the default for Application Insight, it is very useful one to app and it is almost free. I will cover more about this in a different post.
  6. Deployment is complete by clicking Create button.

Now you will see “Your deployment is underway” message, please be patience and give few minutes time for the process to complete.

After the deployment is complete, you may go the created resource. By clicking App Services from All Services menu, you can see our newly created app service “karthiktechblog-shopping-api”.

Click on it and you can see the details of the created app service.

deployment status of azure app service API App

According to Microsoft, there are many free services for 12 months and always free services. You can refer this information in the FAQ mentioned in the this link.

Conclusion

In this post, I have shown how to Create Azure App Service API Apps. This post is part of learning track for azure AZ-203 certification. In the upcoming post, I will cover how to create API App and deploy the application to this Web App and API App.

That’s all from this post. If you have any questions or just want to chat with me, feel free to leave a comment below.

The post How to: Create an Azure App Service API app appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2020/01/07/how-to-create-an-azure-app-service-api-app-for-free/feed/ 1 290
How to: Create Azure App Service Web Apps https://blogs.learnsmartcoding.com/2020/01/07/how-to-create-azure-app-service-web-apps-for-free/ https://blogs.learnsmartcoding.com/2020/01/07/how-to-create-azure-app-service-web-apps-for-free/#respond Tue, 07 Jan 2020 16:32:19 +0000 https://karthiktechblog.com/?p=274 Introduction In this post, I’m going to cover topic “create an Azure App Service Web App”. The details in this post will help to cover a part of knowledge required to complete Azure AZ-203 certification. Let’s focus on the one of the five below topic that is part of skills measured under “Develop Azure Platform […]

The post How to: Create Azure App Service Web Apps appeared first on Learn Smart Coding.

]]>
Introduction

In this post, I’m going to cover topic “create an Azure App Service Web App”. The details in this post will help to cover a part of knowledge required to complete Azure AZ-203 certification.

Let’s focus on the one of the five below topic that is part of skills measured under “Develop Azure Platform as a Service compute solution“.

To know more on AZ-203 certification, visit my detailed post “EXAM AZ-203: DEVELOPING SOLUTIONS FOR MICROSOFT AZURE

Getting Started

In order to start with Azure, you need Azure subscription. To follow along this post, you may use your subscription that you have or create a one for Free. Yes, it is free. Check this link for more details Free Azure

Why we need to Create Azure App Service Web Apps ?

According to App service documentation,

“Azure App Service enables you to build and host web apps, mobile back ends, and RESTful APIs in the programming language of your choice without managing infrastructure. It offers auto-scaling and high availability, supports both Windows and Linux, and enables automated deployments from GitHub, Azure DevOps, or any Git repo.”

By Microsoft

Create App Service

The process of creating app service is simple. Follow the below steps and you can refer the screenshot. Most of the below steps is common while creating a new resource for any services in Azure.

Create Azure App Service
Create App Service
  1. Choose a subscription you have. E.g. If you have created a free account, you will see “Free trial” as subscription. I have Pay as you go plan so I have chosen that.
  2. Choose a resource group or create one. This helps to group various resource together.
  3. Provide a unique name for the app service.
  4. Choose code since we are going to see how to publish a web application in our upcoming post. I will explain how to publish a docker container in a separate post.
  5. Choose a run time stack that suits the best for your application. In my case, I’m going to publish a .net core 2.2 version web app.
  6. choosing windows as operating system will reduce cost.
  7. choose a region that is close your location
  8. Name a plan or leave the default
  9. This is important to choose. As per the demand, you may choose your required plan. Since it is a demo, I have chosen Free F1 Shared infrastructure, 1 GB memory plan.
Create Azure App Service
Create Azure App Service for free

Click on review and create button. Confirm the selection and the service will be created.

Now you will see “Your deployment is underway” message, please be patience and give few minutes time for the process to complete.

Once the deployment is completed, you may go the created resource. By clicking App Services from All Services menu, you can see our newly created app service “karthiktechblog-shopping”.

Click on it and you can see the details of the created app service.

dashboard for Create Azure App Service web app

Benefits of Azure App Service

With the free azure app service that I have created in this post, I will be able to host any web, mobile, or API apps with Azure App Service with 1 GB storage. This is always free according to Microsoft and you can refer this information in the FAQ mentioned in the this link.

Conclusion

In this post, I have shown how to Create Azure App Service Web Apps. This post is part of learning track for azure AZ-203 certification. In the upcoming post, I will cover how to create API App and deploy the application to this Web App and API App.

That’s all from this post. If you have any questions or just want to chat with me, feel free to leave a comment below.

The post How to: Create Azure App Service Web Apps appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2020/01/07/how-to-create-azure-app-service-web-apps-for-free/feed/ 0 274
Exam AZ-203: Developing Solutions for Microsoft Azure https://blogs.learnsmartcoding.com/2019/12/26/exam-az-203-developing-solutions-for-microsoft-azure/ https://blogs.learnsmartcoding.com/2019/12/26/exam-az-203-developing-solutions-for-microsoft-azure/#respond Thu, 26 Dec 2019 08:37:30 +0000 https://karthiktechblog.com/?p=247 Introduction In this post, we will see the skills measured for the Exam AZ-203: Developing Solutions for Microsoft Azure and various examples for exam preparation. Note: The content of this exam was updated on November 6, 2019. I have highlighted in bold where the content is updated as of November 6, 2019. This exam retired […]

The post Exam AZ-203: Developing Solutions for Microsoft Azure appeared first on Learn Smart Coding.

]]>
Introduction

In this post, we will see the skills measured for the Exam AZ-203: Developing Solutions for Microsoft Azure and various examples for exam preparation.

Note: The content of this exam was updated on November 6, 2019. I have highlighted in bold where the content is updated as of November 6, 2019.

This exam retired on August 31, 2020. A replacement exam, AZ-204, is available. For more information, visit the AZ-204 exam details page.

There are several sections in each skill measured. I will be posting examples for each skill that is measured under this exam. By going through those posts, you will be able to cover this exam preparation.

Examples for each skill will have links on it, click on the link to navigate to the post.

However, I will recommend you to learn and practice more on each topic to be an expert.

Skills Measured: Developing Solutions for Microsoft Azure (AZ-203)

Develop Azure Infrastructure as a Service compute solutions (10-15%)

This part is further divided into three more sub-skills and they are measured as below.

Implement solutions that use virtual machines (VM)

  • provision VMs
  • create ARM templates
  • configure Azure Disk Encryption for VMs

Implement batch jobs by using Azure Batch Services

  • manage batch jobs by using Batch Service API
  • run a batch job by using Azure CLI, Azure portal, and other tools
  • write code to run an Azure Batch Services batch job

Create containerized solutions

  • create an Azure Managed Kubernetes Service (AKS) cluster
  • create container images for solutions
  • publish an image to the Azure Container Registry
  • run containers by using Azure Container Instance or AKS

Develop Azure Platform as a Service compute solution (20-25%)

This part is further divided into four more sub-skills and they are measured as below.

Create Azure App Service Web Apps

Create Azure App Service mobile apps

  • add push notifications for mobile apps
  • enable offline sync for mobile app
  • implement a remote instrumentation strategy for mobile devices

Create Azure App Service API apps

Implement Azure functions

  • implement input and output bindings for a function
  • implement function triggers by using data operations, timers, and webhooks
  • implement Azure Durable Functions
  • create Azure Function apps by using Visual Studio
  • implement Python Azure functions

Develop for Azure storage (15-20%)

This part is further divided into four more sub-skills and they are measured as below.

Develop solutions that use storage tables

  • design and implement policies for tables
  • query table storage by using code
  • implement partitioning schemes

Develop solutions that use Cosmos DB storage

  • create, read, update, and delete data by using appropriate APIs
  • implement partitioning schemes
  • set the appropriate consistency level for operations

Develop solutions that use a relational database

Develop solutions that use blob storage

  • move items in Blob storage between storage accounts or containers
  • set and retrieve properties and metadata
  • implement blob leasing
  • implement data archiving and retention
  • implement Geo Zone Redundant storage

Implement Azure security (10-15%)

This part is further divided into three more sub-skills and they are measured as below.

Implement authentication

  • implement authentication by using certificates, forms-based authentication, or tokens
  • implement multi-factor or Windows authentication by using Azure AD
  • implement OAuth2 authentication
  • implement Managed identities/Service Principal authentication •
  • implement Microsoft identity platform

Implement access control

  • implement CBAC (Claims-Based Access Control) authorization
  • implement RBAC (Role-Based Access Control) authorization
  • create shared access signatures

Implement secure data solutions

  • encrypt and decrypt data at rest and in transit
  • create, read, update, and delete keys, secrets, and certificates by using the KeyVault API

Monitor, troubleshoot, and optimize Azure solutions (10-15%)

This part is further divided into three more sub-skills and they are measured as below.

Develop code to support scalability of apps and services

  • implement autoscaling rules and patterns (schedule, operational/system metrics, singleton applications)
  • implement code that handles transient faults
  • implement AKS scaling strategies

Integrate caching and content delivery within solutions

  • store and retrieve data in Azure Redis cache
  • develop code to implement CDN’s in solutions
  • invalidate cache content (CDN or Redis)

Instrument solutions to support monitoring and logging

  • configure instrumentation in an app or service by using Application Insights
  • analyze and troubleshoot solutions by using Azure Monitor
  • implement Application Insights Web Test and Alerts

Connect to and consume Azure services and third-party services (20- 25%)

This part is further divided into five more sub-skills and they are measured as below.

Develop an App Service Logic App

  • create a Logic App
  • create a custom connector for Logic Apps
  • create a custom template for Logic Apps

Integrate Azure Search within solutions

  • create an Azure Search index
  • import searchable data
  • query the Azure Search index
  • implement cognitive search

Implement API Management

  • establish API Gateways
  • create an APIM instance
  • configure authentication for APIs
  • define policies for APIs

Develop event-based solutions

  • implement solutions that use Azure Event Grid
  • implement solutions that use Azure Notification Hubs
  • implement solutions that use Azure Event Hub

Develop message-based solutions

  • implement solutions that use Azure Service Bus
  • implement solutions that use Azure Queue Storage queues

For more details and latest update, visit https://docs.microsoft.com/en-us/learn/certifications/exams/az-203

Conclusion

In this post, you got to know what skills are measured for the Azure AZ-203 Developing Solutions for Microsoft Azure certification and links to various examples for the exam preparation.

That’s all from this article. If you have any questions or just want to chat with me, feel free to leave a comment below.

The post Exam AZ-203: Developing Solutions for Microsoft Azure appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2019/12/26/exam-az-203-developing-solutions-for-microsoft-azure/feed/ 0 247
Configure Azure SQL relational database using vs 2019 https://blogs.learnsmartcoding.com/2019/10/19/configure-azure-sql-database-and-migrate-changes-using-dotnet-cli/ https://blogs.learnsmartcoding.com/2019/10/19/configure-azure-sql-database-and-migrate-changes-using-dotnet-cli/#respond Sat, 19 Oct 2019 12:49:25 +0000 https://karthiktechblog.com/?p=226 Introduction In this post, we will see how to configure the Azure SQL database using vs 2019. This post is a continuation of how to provision a relational database. To read more about how to provision the relational database in the Azure portal, take a look at my post provision and configure relational databases azure […]

The post Configure Azure SQL relational database using vs 2019 appeared first on Learn Smart Coding.

]]>
Introduction

In this post, we will see how to configure the Azure SQL database using vs 2019. This post is a continuation of how to provision a relational database.

To read more about how to provision the relational database in the Azure portal, take a look at my post provision and configure relational databases azure portal

Demo Application Overview

In this demo, we will see how to create a small shopping API application by designing its database schema with minimum tables required for demo.

Once we design our database, we will see how to migrate these changes to the Azure SQL database using DOTNET CLI.

This demo application is created using Visual Studio 2019 and in DOTNET CORE 2.2

In my previous post, I have explained how to provision relational databases in the Azure portal. You may read the post to set up the new SQL database in the Azure portal.

Application Architecture

I have created this application with standard architecture addressing the separation of concerns. We have the following layers in our application.

  • API (Main project)
  • CORE
  • CrossCutting
  • Service
  • Data

The full demo application is available for free and you may download from my GitHub repository.

Database schema to configure Azure SQL database

We have three tables namely Category, Product and ProductImages. Each product will be under a Category and each product might have more than one image to show.

Based on this we will start our relationship in our model. All the entities will go to the Core project.

using System.ComponentModel.DataAnnotations;

namespace KarthikTechBlog.Shopping.Core
{
    public class Category
    {
        public int Id { get; set; }
        [Required]
        [MinLength(2), MaxLength(200)]
        public string Name { get; set; }
        public Status Status { get; set; }
    }
}

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace KarthikTechBlog.Shopping.Core
{
	public enum Status
    {
        InActive = 0,
        Active = 1,
        Suspended = 2
    }
	
    public class Product
    {
        public int Id { get; set; }
        [Required]
        [MinLength(5), MaxLength(200)]
        public string Name { get; set; }
        public decimal Price { get; set; }
        public DateTime? AvailableSince { get; set; }
        public int StockCount { get; set; }
        public int CategoryId { get; set; }
        public Category Category { get; set; }
        public List ProductImages { get; set; }
        public Status Status { get; set; }

    }
}

using System.ComponentModel.DataAnnotations;

namespace KarthikTechBlog.Shopping.Core
{
    public class ProductImages
    {
        public int Id { get; set; }
        [Required]
        [MinLength(128), MaxLength(128)]
        public string ImageId { get; set; }
        public int ProductId { get; set; }
        public Product Product { get; set; }
        public Status Status { get; set; }
    }
}

To follow along with me, download or clone the demo application from the GitHub URL .

Database Migrations

Open the project folder “KarthikTechBlog.Shopping.Data” using the command line.

I’m going to show how to generate a migration script and update the database using DOTNET CLI.

dotnet ef migrations add initalcreate -s ../KarthikTechBlog.Shopping.API/KarthikTechBlog.Shopping.API.csproj

In this, we are creating a migration script named “initialcreate” and specifying our startup project by specifying “-s project-path“. Once you create migration using the above command, you can see the migration folder added to your project.

dotnet ef database update -s ../KarthikTechBlog.Shopping.API/KarthikTechBlog.Shopping.API.csproj

To push the created migration script to our database, run the above command.

Conclusion

In this post, you learned how to configure relational databases with azure SQL database using Visual Studio 2019 and DOTNET CLI.

That’s all from this post. If you have any questions or just want to chat with me, feel free to leave a comment below. If you want to get a continuous update about my blog, make sure to follow me on Facebook and Twitter.

The post Configure Azure SQL relational database using vs 2019 appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2019/10/19/configure-azure-sql-database-and-migrate-changes-using-dotnet-cli/feed/ 0 226
Setting up CI pipeline for angular application using Azure DevOps Build https://blogs.learnsmartcoding.com/2019/10/12/setting-up-ci-pipeline-for-angular-application-using-azure-devops-build/ https://blogs.learnsmartcoding.com/2019/10/12/setting-up-ci-pipeline-for-angular-application-using-azure-devops-build/#respond Sat, 12 Oct 2019 14:14:36 +0000 https://karthiktechblog.com/?p=168 Introduction to CI pipeline for angular application In this post, I will explain step by step process for setting up CI pipeline for the angular application using Azure DevOps Build. It is easy to set up continuous integration (CI) build for Angular application using Azure DevOps build. Before we get started, see take a look […]

The post Setting up CI pipeline for angular application using Azure DevOps Build appeared first on Learn Smart Coding.

]]>
Introduction to CI pipeline for angular application

In this post, I will explain step by step process for setting up CI pipeline for the angular application using Azure DevOps Build. It is easy to set up continuous integration (CI) build for Angular application using Azure DevOps build.

Before we get started, see take a look at Prerequisite below.

Prerequisite for CI pipeline for angular application

  • Azure DevOps account. If you don’t have an account, you may create at https://azure.microsoft.com/en-us/services/devops/. It is free!
  • Once you have your account, you need an Organization and a Project.
  • Last but not least, you need an Angular project in a repository.

Let’s configure our package.json file in the Angular application to include a script as shown below. This will be used while we configure our build.

"prepush": "npm run build --prod" 

Let’s get started…

Create a New Build Pipeline

Navigate to your organization and choose the project in which you have your angular project repository. You will have to select a build from the left menu.

CI pipeline for angular application

Click on "New" => "New build pipeline" as shown in the below image.

CI pipeline for angular application
New build pipeline

There are two ways of setting up a CI build. One is using “Classic Editor” and the other one is using “YAML“. We are going to see CI build setup using “Classic Editor” in this post.

where is your code?

Where is your code?

In this step, we need to choose the place where our repository exists. In our case, it is in the Azure git repository. Next is to select Project, Repository where your angular project code exists and lastly, select the branch. e.g. master.

Select a template

We are setting up CI for the angular project. In this case, we should choose one of the templates required for the angular projects. Since we do not have anything that supports our needs, we will choose “Empty Job“.

select a template

Configuring Tasks

We need to configure a couple of tasks to build our angular application. The first step is to provide basic information for the top-level selection.

Under “Pipeline“, provide the below information.

  • Name. some meaningful name to understand our pipeline. E.g. we are setting up a build for our Web project for the master branch. E.g. “Web-master-CI”.
  • Select “Azure Pipelines” as the Agent pool.
  • Select “vs2017-win2016” as Agent specification. This is a virtual machine sitting somewhere in the cloud which will build our angular application.

Configure Get Resource

This step is to verify our existing selection, select as shown in the image below.

Adding Tasks

The first task is to add “npm install” task.

adding tasks
Configure the task

Configure the task as shown in the image.

Configure the task

The second task is to add “npm build” task.

CI pipeline for angular application

Configure the task as shown in the image.

CI pipeline for angular application

Third and final task is to add “publish build artifacts” task.

CI pipeline for angular application

Configure the task as shown in the image.

CI pipeline for angular application

We can save and queue the pipeline.

CI pipeline for angular application

That’s it, we are done setting up CI build for our angular application. Once the build is done you will see the message as shown below.

CI pipeline for angular application

To check the build details and the package, click on the “summary” tab as shown in the image below.

CI pipeline for angular application

Conclusion

In this article, you learned how to set up a CI pipeline for the angular application using Azure DevOps build.

That’s all from this post. If you have any questions or just want to chat with me, feel free to leave a comment below. If you want to get continuous updates about my blog, make sure to follow me on Facebook and Twitter.

The post Setting up CI pipeline for angular application using Azure DevOps Build appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2019/10/12/setting-up-ci-pipeline-for-angular-application-using-azure-devops-build/feed/ 0 168