Tuesday, 19 November 2019

Setup Azure CI/CD Pipelines using Visual Studio Part-2


In the previous article, we saw, how to configure CI/CD for a single project solution. In this article, we will see how to configure CI/CD for multiple project solutions.
Before going forward, please go through the previous article.
I’m not going to spend time on what is Azure DevOps and its feature, we are directly moving to CI/CD for multiple project solution. How can we configure this with the help of visual studio and TFS? We will see this step by step. Once we set up the Azure Pipeline then on each check-in it will build the application and deploy the changes on App Service according to the project.
To know about Azure DevOps and its other features, you can refer to the below blog.

Prerequisite
For configuring the Azure DevOps CI/CD, you need the following tools.
  1.  Azure DevOps account
  2. Azure Portal Account
  3. Visual Studio 2012+(in my example I am using VS 2017 and 2019)


Steps:
We will see how to configure CI/CD and setup Azure Pipeline using Azure DevOps.

Step 1:
Create a new project by using the Azure DevOps account. I am using Team Foundation version control, but you can use Git too.


Create Project on Azure DevOps

Step 2:
Configure the newly created project in Visual studio source control on your local system.

Configure Source Control

Step 3:
In the previous article, we created a new project with a solution in Visual Studio, now we are going to add another project under the same solution and add check-in the changes.


Create a Project with name CICD_App2


Added project in Solution control


CICD_App2 Running Successfully

Step 4:
Create a blank solution inside the CICD_App2 project folder.


Blank Solution


Creating a Blank Solution
Step 5:
Add CICD_App2 Project in the newly created blank solution.


Adding Project


Select .csproj file in order to add a project in the solution

Step 6:
Setup Azure Pipelines under the publish settings of your solution.


Setup Azure Pipeline
Step 7:
Wait for a few mins and then go the pipelines under Azure DevOps. You will see a new Pipeline created and the build of the project has started.


DevOps Pipeline Created

Step 8:
Check the Deployment Center on the Azure portal for your App Service, for which you have set up the Azure Pipeline in step 6.


Azure App Deployment Center

Step 9:
If there is no error in the build, then after some time your build has succeeded. It is taking a few mins. In my example, it takes up to 2 min.


Build Succeeded
Step 10:
It will also create a release as shown in the previous article, but in this article, I am going to show you how to create and configure a release manually.
Under the Releases, the option creates a new release.


New Release Pipeline
Step 11:
Select a template (Azure App Service Deployment) for stage and then add the Build Artifacts with Continuous Deployment Trigger.


Template Selection


Artifacts


Continuous Deployment Trigger
Step 12:
Create a task under the task option, add the options correctly when you are creating a task.


Create Task
Now, you are ready to create a release.


Creating Release Option


Create Release

Step 13:
After the release created it will start to deploy the changes on the App Service.


Released Successfully
Step 14:
Check the App by using URL and you will see the application has deployed.


App Service URL after First Release

Step 15:
Change anything in the application, check-in the changes and see Azure DevOps will build the solution and release the changes.


Heading change



After build completed, new changes are deployed

Step 16:
Now we are going to change the code in both projects and check-in those in the single check-in. Then we will see how both projects are building separately and deploy the changes in different app services accordingly.


Changes in Default.aspx pages under both project


The build has started for both projects


Released the changes of both projects


Changes have deployed

Note: We can see all Releases under Deployment Center on Azure Portal.
We need a separate .sln file to configure the CICD for each project.


Wednesday, 30 October 2019

Setup Azure CI/CD Pipelines using Visual Studio


Today, We are going to see how to configure Azure DevOps CI/CD and setup Azure Pipeline using visual studio.

Not spending the time on what is Azure DevOps and its feature, we are directly moving to CI/CD. How can we configure this using visual studio? We will see this step by step. Once we set up the Azure Pipeline then on each check-in it will build the application and deploy the changes on App Service.

In this article, we will see how to configure the CI/CD for a single project in one solution. In the next article, we will see how to configure the CI/CD for multiple projects in one solution.

To know about Azure DevOps and its other features, you can refer to the below blog.

Prerequisite
For configuring the Azure DevOps CI/CD, you need the following tools.

  •   Azure DevOps account
  •  Azure Portal Account
  •   Visual Studio 2012+(in my example I am using VS 2019)


Steps: We will see how to configure CI/CD and setup Azure Pipeline using Azure DevOps.
Step 1:
Create a new project by using the Azure DevOps account. I am using Team Foundation version control, but you can use Git too.




Create Project on Azure DevOps

Step 2:
Configure the newly created project in Visual studio source control on your local system.


Configure Source Control

Step 3:
Create a new project with a solution in Visual Studio and add this in DevOps Source Control then check-in the changes.



Create a New Project with Solution



Creating Project and Solution



Added project in Solution control
Step 4:
Setup Azure Pipelines under the publish settings of your solution.



Setup Azure Pipeline
Step 5:
Wait for a few mins and then go the pipelines under Azure DevOps. You will see a new Pipeline created and the build of the project has started.



DevOps Pipeline Created

Step 6:
Check the Deployment Center on the Azure portal for your App Service, for which you have set up the Azure Pipeline in step 4.


Azure App Deployment Center

Step 7:
If there is no error in the build, then after some time your build has succeeded. It is taking a few mins. In my example, it takes up to 1min 21 sec.



Build Succeeded
Step 8:
As the build succeed the new release would be created and started pushing the release changes on App service.


Release the changes
Step 9:
Check the App by using URL and you will see the application has deployed.



App Service URL after First Release

Step 10:
Change anything in the application, check-in the changes and see Azure DevOps will build the solution and release the changes.


Heading change



Build has started



After build completed the Release as created



Changes are deployed

Note: We can see all Releases under Deployment Center on Azure Portal.



Azure App Deployment Center

In the next article, we will see how to configure the CI/CD for multiple projects in one solution.

Thursday, 26 September 2019

Schedule Azure WebJobs Using Azure Logic Apps

In this article, we will see how to migrate Azure WebJobs from Azure Scheduler to Azure Logic Apps. As we all know, Azure Scheduler will become obsolete on December 31, 2019, after this, all Scheduler job collections and jobs will stop running and will be deleted from the system. In order to continue to use jobs, we must move Azure Schedulers to Azure Logic Apps as soon as possible. Azure Logic Apps have numerous features which are as below,
  • Uses a visual designer and connectors to integrate with more than 200 different services, including Azure Blob storage, Azure Service Bus, Microsoft Outlook, and SAP.
  • Manages each scheduled workload as a first-class Azure resource.
  • Runs multiple one-time jobs using a single logic app.
  • Sets schedules that automatically adjust to daylight saving time.
For more details about its features and usage, please refer to the below article.
Before going further, let’s know something Azure WebJobs.
 
WebJobs is a feature of Azure App Service that enables you to run a program or script in the same context as a web app, API app, or mobile app. There is no additional cost to use WebJobs. For more detail please refer to the below article.
Now, we will see step by step, how to schedule Azure WebJobs using Azure Logic Apps.
 
Step 1
 
Create and deploy an on-demand (triggered) job under Azure App Service. Click here to learn how to create and deploy a WebJob.


Create and deploy webjob
 
Step 2
 
Create a blank Logic App.
 
Logic App
 
Step 3
 
Edit the logic app and select a Recurrence type of Schedule trigger.
 
Logic App Designer
 
Step 4
 
Set the interval, as per your requirement. Also, you can set other parameters like Time Zone and Start Time as shown in the below image. In my case, I am going to set 1 minute without any extra parameter.
 
Logic App Designer
 
Step 5
 
After trigger configuration, now its time to set HTTP action with post method and basic authentication.
 
HTTP Request
  1. "inputs": {  
  2.    "authentication": {  
  3.     "password""password",  
  4.        "type""Basic",  
  5.        "username""$username"  
  6.         },  
  7.     "method""POST",  
  8.     "uri": https://appname-webjob.scm.azurewebsites.net/api/webjobtype/webjobname/run  
  9.   },  
HTTP Post
 
Notewe can get the basic authentication from publish profile of an application where we have deployed the WebJob.
 
Step 6
 
Run the Logic App and check the status under run history.
 
Logic App Run History
 
WebJob Run History
 
Note
You can download the code and copy and paste it in the code view. Change your credentials and URI according to your WebJob; your Recurrence type Logic App is ready.

Expected Results
 
The Logic App has configured correctly, and it is working as expected. It is running the Azure WebJob as per the set frequency. If there is an error in the WebJob then your run will fail, and you can see it under Run History.
 

Summary

 
In the above article, we have learned how to schedule the WebJobs using Azure Logic Apps. In reference to the article given above, we noticed that the Azure Scheduler is scheduled to retire fully on December 31, 2019, and All Scheduler job collections and jobs will stop running and they will be deleted from the system simultaneously. So, before that, we need to shift Azure Scheduler jobs to Azure Logic Apps.