Showing posts with label Azure DevOps. Show all posts
Showing posts with label Azure DevOps. Show all posts

Saturday, 19 December 2020

Add Project Code into Azure DevOps through Visual Studio and Command Line

There are a couple of ways to add a new project or existing project in the DevOps. Let’s take the example of an existing offline project and you want to check-in to DevOps.

Push the code through Visual Studio


Before that, you need a Repository in the DevOps. I hope you already have, If not, let’s first create the new Repo in the Azure DevOps 

Step 1: Go To Azure DevOps, create a new repository in your Project. If you don’t have any project in your DevOps then first create a new project. In my example, I already have a project, so I’m creating a brand new repository in this.

Step 2: Click on the new repository option and create a new repo.








Step 3: Specify the Repository name and press the create button and it will create a new repo.













Step 4: Click on the clone button and copy the URL.













The repository is ready and let’s learn how to push code in this repo through Visual Studio.

Step 5: Open your existing/newly created project in Visual Studio.
Step 6: Right-click on the solution file and click add the solution to source control.













Now you can see the lock symbol in the files. In Team Explorer, Branches, you can see it has created a new Master branch. If you don't see this option in the Visual Studio then you can choose the alternate option, push the code through the command line, mentioned below.

Step 7: Go to team explorer, Click on the Sync tab, and select the push Git Repo button.
Step 8: Enter the URL that we have copied above in the Clone option and press publish.












Now you can see the code in the master branch in Azure DevOps. If you are on the main branch then, you need to switch to the master branch in Azure DevOps.
















Let's learn another way to push the code to Azure DevOps.

Push the code through the Command line

I have created a blank .Net Core project in my Visual Studio and created new blank Repo in Azure DevOps name SecondRepo. Now, will push that code through the command line.

Step 1 to Step 4 is the same.

Step 5: Go to your project location and open the command prompt.
Step 6: Create a Git repo on your machine to store your code by running the below command.

          git init





Step 7: Commit your code into the local git repository and run the below commands

        git add --all
        git commit -m "first commit through command line"

Step 8: Connect your local repo to the Git repo in Azure Repos using the command mentioned below and enter your repo URL.
                


Step 9: Push the code.

        git push origin master
















Now, if you go to Azure DevOps, you can see all the code in the repository.























This is all about this article. I hope you like it.


Monday, 1 June 2020

Deploy Angular/Vue/React App to Azure Portal through Azure DevOps CI/CD


Overview

Today we will learn how to deploy the angular app to Azure Portal through CI/CD. For this, first of all, you need to create new App Services in the Azure portal. You can follow the first 3 steps as mentioned in the link below. Below URL is to deploy the angular app manually through Visual studio code.



Once your app service is ready then make sure code is check-in the Azure DevOps. The first step is to create a new build.

Step 1: Build a Pipeline

Login to Azure DevOps and click on the Pipeline link as shown in the snapshot below and then press New Pipeline











Step 2: Specify where is your code?

I'm selecting Other Git options for the angular app as our code exists in the Azure DevOps Repo.
























Step 3: Select a source

Specify your Project and repository as shown below























Step 4: Select a template

I'm selecting an empty job here. So, we perform all the steps manually here.










Step 5: Add New Tasks

In the pipeline Task, you can specify the default Agent pool and specifications.
Get sources Task, Project, and Repository is already selected. if not, select your project.
Add your 3 new tasks, as shown below.

  1. Npm task
  2. Npm task
  3. Publish build artifact

1. You need to press the "+" symbol and add a new npm task here. The First npm task is to install all npm package that is required for the angular app.

2. The second npm task is to build the project. I'm selecting custom command here and specify the working folder where you package.json exists.
Then write build command. In my example, we have run the build command 

















OR












You can add build:prod for production env.















3. Add a new publish artifact task and specify the path to publish, it should be in the dist folder. In my case, it is in the folder/dist. your package.json might be outside the folder then you will write only dist and specify the artifact name, it can be anything.

















OR












Step 6: Press the save and queue button.

You can see the build has succeeded and will create artifacts for you.



























Step 7: Create a release

Click on the release button as shown in the snapshot below and click the "Create Release" button.



Step 8: Select the template


We will select the default template i.e Azure App Service deployment



Step 9: Add an artifact

Specify your Project and build pipeline here, so it can pick the code from that pipeline.

Step 10: Select the Deploy Azure app service task

Specify the following options

  1. Connection Type
  2. Subscription (Your Azure Subscription)
  3. App Service Type (it should be a Web app) as we have an angular app.
  4. App Service Name (Once you select the subscription, it will automatically fetch all the Web App that you have created on Azure Portal). Select that app service name here.























Step: 11 Create the release.

Once the release is succeeded, It will automatically deploy all the code to the Azure web app.
















This is all about this article and let me know if you have any questions.

How to get PowerBI Embed Token

 Here's a step-by-step guide to help you through the process. Step 1: Register Your App in Azure 1. Go to Azure Portal → App registratio...