Tuesday, October 8, 2019

Create and Share Metrics Dashboard in Azure


Create and Share Metrics Dashboard in Azure

Image result for azure metrics icon

You can create & share Azure Portal dashboard to other users or group with having access to the same Azure Subscription. Azure allows you to create  your required dashboards such as metrics for azure service & Azure service health dashboard, or any other Azure services monitoring dashboard , so that we could keep track of what is happening in our services . you can share dashboard with other in case they need same. In this post let’s have a quick look at how we can share a dashboard and give necessary access to users.
Create Azure Portal Dashboard
To understand how can we create a new, private dashboard and assign a name. Follow these steps to get started:
1.    Sign in to the Azure portal.
2.    Select Dashboard from the upper section of the left sidebar. Your default view might already be set to dashboard.
3.    Select + New dashboard.


For my demo I have AppService which is up and running and here I’ll be creating a dashboard to monitor an AppService running status.

Kindly go to AppService and find “metrics” there as depicted in given below screenshot app-metrics




From the metric dropdown I have selected CPU runtime to see the CPU utilization of an application and click on pin to dashboard.
Once you click on “Pin to dashboard”  there will be an another option “select another dashboard” to pin it. As shown in below screen shot select-another-dashboard.


 Once you click on that a new window will appear on the right , fill the required details to create new dashboard within the subscription , you can choose another subscription as per your need and click apply. After few seconds dashboard will have created and a link will be there at bottom of screen to jump directly to dashboard
Refer a screen shot depicted below : create-new-dashboard.





After clicking on Monitor AppService , it will open the dashboard ,where you should be able to see the CPU metrics board, point to notice is it has shared already once you create that, you will be able to see the Unshare button on top of the screen.  as shown in image below : unshare-dashboard


The same way you can create few more metrics into existing dashboard.
You can also see all dashboard from the search as well by typing shared dashboard ,it will show you each shared dashboard within subscription.
Refer- shared-dashboard



I wish it will help you to create Shared Dashboard, in coming Article will explain you how can we place RBAC policy on dashboard.


Thursday, September 26, 2019

Integrate an Azure Alert with action group in Availability Test  in Azure

This is really interesting to implement to check an availability of you webapp/AppService . Azure leverage you to do this. You can set up recurring tests to monitor an availability on intervals from difference geographical point around the world.
An Important factor is , it can raise an alert on that basis if certain condition doesn’t meet.

An excerpt from doc.microsoft.com

Types of availability tests:
There are three types of availability tests:
·         URL ping test: a simple test that you can create in the Azure portal.
·         Multi-step web test: A recording of a sequence of web requests, which can be played back to test more complex scenarios. Multi-step web tests are created in Visual Studio Enterprise and uploaded to the portal for execution.
·         Custom Track Availability Tests: The TrackAvailability() method can be used to create your own custom availability tests.


NOTE: You can create up to 100 availability tests per Application Insights resource.

Prerequisites: Application Insights resource

In order to create Test , first create an application insight for the specific resource. I assume you understand how to create an application insight for AppService.

As soon as you have created Application Insight, its time to create a availability test case in azure using Azure Portal.

You can see an application insight option in AppService left pane as depicted in image app-insights





















Click on that and it will take you on the following screen as shown below screen view-app-insights












Click on View Application Insights data and proceed further to see detailed application insights refer screen  below detailed-app-insight














Kindly find Availability option on the left panel of screen and click , once you click it will open a screen to create Add Test . Fill the required details of your endpoint to verify its availability from different geography. Refer screen add-test













Refer an image below to understand what value we should fill for the respective fields which appears on the screen. Add-test-complete-details
































Each field is self explanatory though there are few which may be bit confusing so follow the below excerpt:

Parse dependent requests : When enabled, the test requests images, scripts, style files, and other files that are part of the web page under test. The recorded response time includes the time taken to get these files. The test fails if all these resources cannot be successfully downloaded within the timeout for the whole test. If this option is not enabled, the test only requests the file at the URL you specified.

Enable retries for availability test failures : If the test fails, we’ll try it again after 20 seconds. We’ll record a failure only if it fails three times in a row.


Success criteria


Setting
Explanation
Test timeout
Decrease this value to be alerted about slow responses. The test is counted as a failure if the responses from your site have not been received within this period. If you selected Parse dependent requests, then all the images, style files, scripts, and other dependent resources must have been received within this period.
HTTP response
The returned status code that is counted as a success. 200 is the code that indicates that a normal web page has been returned.
Content match
A string, like "Welcome!" We test that an exact case-sensitive match occurs in every response. It must be a plain string, without wildcards. Don't forget that if your page content changes you might have to update it. Only English characters are supported with content match

Availability test results

Test results can be seen in form of Scatter plot and Line views, After a few mins click refresh your test results.

It appears with the following details refer screen availability-test-successful.






Edit an Alert in Availability test

Azure allows you to integrate an alert with a ping test for AppService , To achieve that just click on “…” and edit alert , a new window will appear where you can set your alert mechanism to get a notification. Refer edit-alert screen shot below:





Enable it and select an action group or create an action g
roup.
To create an action group refer this page .
In short action group is collection of different notifications or intimation to group of members, Action group takes an anticipated action to resolve issue for an alert already raised .Refer a screen shot action-group as shown below.


After choosing desired action group than save an alert. Each alert specifies a condition like  Whenever the Failed locations is Greater than or equal to 2 count
If an above condition doesn’t meet while availability test it triggers an alert to send a notification to Action Group.


I hope it will help you to manage alerting system in Availability Test case.







To edit, temporarily disable, or delete a test click the ellipses next to a test name. It may take up to 20 minutes for configuration changes to propagate to all test agents after a change is made.

I hope it will help you while you create Test case for your application. 

Saturday, August 3, 2019



Azure App Insights – Write Test case for AppService Availability





To check you AppService availability is potential when your application is in production and being use by plenty of end users. To write test case in .Net, Java or in other programming language is possible using Nunit ,Junit ,Jasmine and others.
I was astonished with this testing feature, So thought to explore something about it. Yeahh That’s true so lets write Test case in Azure .Trust me it gonna be fun.
I’m utilizing .Net Core based application along with Azure Cosmos DB.



Prerequisites : You should have basic understanding of .Net Core .
Application Insights should be configured for an application like WebApp/AppService
Once you are done, You can should see few resources created within Azure portal as shown in image rg-in-azure



Once you have published an application ,Click on Application Insights (e.g. CosmosDBInsights).After clicking on this it opens AppInsights refer an image shown below application-insights


IN the left pane you should be able to see Availability option till date 3Aug 2019 ,Click on that
After clicking of availability you will see the following screen in order to create you Test to verify an availability of the specific endpoint. Refer image add-test




After clicking on AddTest , A new window will appear on the right side to fill the all necessary details like


  1. TestName,
  2. Test Type
  3.  Specify the URL to test in that,
  4.  Parse dependent request which states “When enabled, the test requests images, scripts, style files, and other files that are part of the web page under test. The recorded response time includes the time taken to get these files. The test fails if all these resources cannot be successfully downloaded within the timeout for the whole test. If this option is not enabled, the test only requests the file at the URL you specified” . Reference portal.azure.com.
  5. . Enable retries for availability test failures
  6.  Test Frequency : The frequency at which this test will be executed periodically.
  7.  Test Location : Choose your test location after keeping thought about users .
  8.  Success Criteria Which requires Http status code returned to equal the value like 200, 400,4040, 500 etc.
  9.  Alerts : There are default alerts configured though classis preview still exists.

You can refer below some screen shots for reference what should you fill in those properties.
Refer image Test-case-details


Once you save it and after the certain time you will see , Test case has started executing and you should be able to see the details in Availability section in form of line chart or Scatter chart. If you expand the arrow button shows below the chart you will find location details about website availability .Kindy refer an image showing below: availability-of-ping-url






This helps you definitely if you want to test specific endpoint availability.

Tuesday, July 30, 2019

ComosDB - MongoAPI - Document does not contain shard key

This issue comes in picture when we forget to put value for Shard Key while inserting values in document. It means once we have declared Shard key for document it should be part of model which is inserting. Kindly refer an images below:

ShardKey of CosmosDB collection

ShardKey in CosmosDB collection's document :


ShardKey in CosmosDB within collection


I Hope it will help you to resolve your problem.

#CosmosDB #Azure

Tuesday, July 23, 2019




Create Linux Virtual Machine using ARM Templates (IaC) in Azure


There are various ways to create virtual machine in azure , Few of them are very well known as shown below:
    
           1    Azure Portal
2      Azure PowerShell
     Azure CLI
4      Create a json template and deploy json template through power shell
5       Create and deploy virtual machine through visual studio console.



In this article I will explain how to create it with Infrastructure as a code or using azure ARM templates.
Practical Scenario : There can be a practical use case while you work in a certain project and gets a requirement to create a virtual machine from an existing infrastructure. There can be various ways though the quickest one is through Azure templates.
Azure templates can be downloaded from the resource already hosted. Now
What ARM templates perform : An ARM templates keeps an entire contents of resource group or it can contain more than one resource. While deployment it can be “Complete or Incremental”.

Whenever you perform any operation through Azure ARM portal, Azure PowerShell ,Azure CLI or Rest API’s the Azure ARM API handles your individual request, because each request handled by the same API.
All the capabilities exists in Azure Resource Manager Portal are easily available through PowerShell, CLI and client SDK as well as RestAPI’s.

You can refer an image below to understand how does all tools interact with ARM API. Refer arm-image






The API transmit request to Azure resource manager service ,which further validates the requests and it further routes the requests to appropriate service.

Now login into https://portal.azure.com and search for existing resource if exists (e.g. Virtual Machine).Open that in portal as shown below in image virtual-machine-linux 






Search templates , it should show export templates in that. Click on that.Kindly refer an image export-template.




Once you click on the export template option shown in last step , it  shows you the following screen ,from there you can download the templates . You should be able to some other options also like CLI, PowerShell, .NET, Ruby. Refer download-template




Once you downloaded the files unzip that ,it has the following structure which contains all  pertinent information about the various ways to deploy you resource to ARM. For our purpose parameters and template.json files are essentials to proceed further. Refer template-structure




template.Json files keeps an entire structure of the resource you want to deploy while parameters contains runtime parameters required in template.Json file.
Parameters.json contains the information like “virtualMachineName”, virtualMachineRG, osDiskType, virtualMachineSize and diagnosticsStorageAccountName.  Parameters.json has the following structure.
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "value": "centralus"
        },
        "networkInterfaceName": {
            "value": "master675"
        },
        "networkSecurityGroupName": {
            "value": "master-nsg"
        },
        "networkSecurityGroupRules": {
            "value": [
                {
                    "name": "SSH",
                    "properties": {
                        "priority": 300,
                        "protocol": "TCP",
                        "access": "Allow",
                        "direction": "Inbound",
                        "sourceAddressPrefix": "*",
                        "sourcePortRange": "*",
                        "destinationAddressPrefix": "*",
                        "destinationPortRange": "22"
                    }
                }
            ]
        },
        "subnetName": {
            "value": "default"
        },
        "virtualNetworkName": {
            "value": "kubeRG-vnet"
        },
        "addressPrefixes": {
            "value": [
                "10.0.0.0/24"
            ]
        },
        "subnets": {
            "value": [
                {
                    "name": "default",
                    "properties": {
                        "addressPrefix": "10.0.0.0/24"
                    }
                }
            ]
        },
        "publicIpAddressName": {
            "value": "node3-ip"
        },
        "publicIpAddressType": {
            "value": "Dynamic"
        },
        "publicIpAddressSku": {
            "value": "Basic"
        },
        "virtualMachineName": {
            "value": "node3"
        },
        "virtualMachineRG": {
            "value": "kubeRG"
        },
        "osDiskType": {
            "value": "Premium_LRS"
        },
        "virtualMachineSize": {
            "value": "Standard_D2s_v3"
        },
        "adminUsername": {
            "value": "sachin"
        },
        "adminPublicKey": {
            "value": null
        },
        "diagnosticsStorageAccountName": {
            "value": "kubergdiag642"
        },
        "diagnosticsStorageAccountId": {
            "value": "Microsoft.Storage/storageAccounts/kubergdiag642"
        },
        "diagnosticsStorageAccountType": {
            "value": "Standard_LRS"
        },
        "diagnosticsStorageAccountKind": {
            "value": "Storage"
        },
        "autoShutdownStatus": {
            "value": "Enabled"
        },
        "autoShutdownTime": {
            "value": "19:00"
        },
        "autoShutdownTimeZone": {
            "value": "UTC"
        },
        "autoShutdownNotificationStatus": {
            "value": "Disabled"
        },
        "autoShutdownNotificationLocale": {
            "value": "en"
        }
    }
}


So far we are done and good to go. Open you PowerShell window and type az login to get into your subscription.
Once you succeeded with  that type the following command to deploy your resource.

az group deployment create -n "sachinDeployment" -g "kubeRG" --template-file 'C:\Learning\LinuxVM\VM\template.json' --parameters 'C:\Learning\LinuxVM\VM\parameters.json' --parameters "adminPublicKey=ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAgQzk/MYIUMhMDpJgjgku6QdhLY0zagTdqFYWkJuTnz9tsBE7eRyFuzW9lK6PSTTSYHCbTPpWALJWGlwrEmWmXL62nss0ppa2IcuD9TMA3VkeFKE6EnOpiRF6lM6fBXyh+KtRFrzHIu6OUfeLbAy6UpPm1kRPcRtMX9nRX0hzpRKGLYdIh/gnwNYJsOHX/5wAvFiDfPSlIblYbL9HhWaw1Mm/b1r6vpV+WREhJ09q2Fh4uQwi75/XuUj9C+2c5NOM5HwKxILdiwad3FcTfNrGO0otHaXdAT0buAbZ7wL4QNKqLtcTelje2BGc6uunpyrYywQkn/VLBETC+LY21S4aBw== rsa-key-20190723"
refer : power-shell-command                 


Note: in my case I’ve passed adminPublicKey as runtime parameter which I have created with help of Agent Putty.
Yeeee , You are done. Go to azure portal and choose virtual machine there.
You should get you virtual machine details there as in my case it has created Node3.



Hope it helps you while you create VM using ARM templates (Infrastructure as Code)






Friday, July 19, 2019




Azure DevOps – New Era – Create New Build Pipeline


Ref : microsoft.com

In my Previous article I shared about “how to start with AzureDevOps and how to create new organization”. https://www.dotnetpiper.com/2019/07/azure-devops-new-era.html AZURE DEVOPS – A NEW ERA Here in this we will proceed further where we left and will create New Build pipeline with the impressive User interface.
Here I have a small application which has the following structure shown below as screen shot app-structure



I have already placed in Azure GitHub , To push your code from VS code you can refer this url :
I’m assume so far you would have pushed your code there and we are ready to go.
Create a new project and follow the following steps
Step1: Refer image create-project-first ,create-project-two and create-project-success








Go to pipeline -> Builds-> New Pipeline and click . refer an image new-pipeline



As soon as you create new pipeline it reaches to the windows from there you would be able to select the classic editor as shown below in screen shot:
So choose Use the classic editor to create a pipeline without YAML.


After completing this you will reach on the page where you will have to select code repository
These repository are as follows:
  1. ·         Azure Repose Git
  2. ·         GitHub
  3. ·         GitHub Enterprise Server
  4. ·         Subversion
  5. ·         Bitbucket Cloud
  6. ·         Other Git

For my purpose I’ve selected Azure Repos Git , which we have already created above.
Kindly refer a screen shot for reference and click on Continue. Refer image Azure-repose-git

 

As soon as you go with above steps it takes you on the page where you have to choose one of the templates which you can consider as ‘Configuration as Code’. For my purpose I will select Empty job as shown top right of screen. Refer image Empty-job



After selecting Empty Job you will be redirecting to next level ,where you should be able to see the Pipeline details as well as Agent Job details on the right side of screen. The entire screen will be divided into two parts.

Kindly fill the desire details like Display Name and AgentPools . Agent Pools is defined as follows
When you queue a build, it executes on an agent from the selected pool. You can select a Microsoft-hosted pool, or a self-hosted pool that you manage.

To reach up to this level you have to click on the (+) icon right to the Agent Job 1 and you will get the screen just on the right side.

Step 1: Firstly, click on the (+) icon to proceed , As soon as you click on the + icon you will have a window appears on the right side . Search for “Copy Files” from and fill the required details. Please follow the screen shots Copy-Files.jpg



Once you select this please fill the essentials details in the page appears. Kindly follow the upcoming screen shots copy-files and target-folder







Target folder is the place where we keep our code base at pipeline level and further we will use this for publishing it.
NOTE: You can understand this in such a way that the local path on the agent where any artifacts(e.g. layman) are copied to before being pushed to their destination. For example: c:\agent_work\1\a 

A typical way to use this folder is to publish your build artifacts with the 
Copy files and Publish build artifacts tasks. Reference Microsoft

Note: This directory is purged before each new build, so you don't have to clean it up yourself.
Step2:
Click on the (+) button next to  Agent Job 1  and choose the publish build artifact. At this level we have to give the path of the folder which we want to publish. As we remember in last step we copied the artifacts in : $(Build.ArtifactStagingDirectory). The same folder  or file path to publish. This can be a fully-qualified path or a path relative to the root of the repository. Wildcards are not supported. Variables  are supported. Example: $(Build.ArtifactStagingDirectory).

There are 4 properties which we will consider in our scenario .

1.     1. Display name :  Name can be anything as per your choice like Publish Artifact: drop
2. Path to publish : The folder or file path to publish. This can be a fully-qualified path or a path relative to the root of the        repository
3.  Artifact name: The name of the artifact to create in the publish location.
4.  Artifact publish location : Choose whether to store the artifact in Azure Pipelines, or to copy it to a file share that must be accessible from the build agent.


Refer and image publish-artifact as shown below:




Step3: Click on the (+) button next to  Agent Job 1  and choose the publish build artifact. Here we will be managing ARM templates for CI-CD pipeline because we are creating resources with help of ARM templates or azure automation . Fill the required details on the page .Please refer an image arm-templates-publish-build-artifacts as shown below:



If you notice, Templates folder is there  in “path to publish”  property. You can get that after clicking on the “…” button right to this. Once you click on this it prompts you a pop-up to choose the path for templates from azure repos as shown in image arm-templates-files. This is mush needed to create our resources on the fly, we will be utilizing this in azure release pipeline further.



Note: I’ll write a separate article on Azure templates also.

Once you are done with all above required steps than choose save & queue option from dropdown 

appears top in the tabs section , as you save , it triggers the build .Kindly find one of the screeb=n shot as 
depicted in image save-and-queue .



You can also trigger it manually from the user interface from the Build pipeline once you have saved your pipeline .There should be a QUEUE button on top right corner , click on Queue button window should appear to run the pipeline . Choose Hosted VS 2017 and choose branch we desire to build against. Once it is completed you should be able to see the green tick mark on the right side.
 Refer build-pipeline image show below: