Latest Microsoft Dynamics 365 Blogs | CloudFronts

Backup Azure DevOps Git Repositories

Here we will see how to backup the repository using the YAML file. This includes the following steps Create an Azure DevOps Personal Access Token (PAT) Create a YAML file Create Subscription Connection Create an Azure DevOps Personal Access Token (PAT) Step 1: Sign in to your Azure DevOps Portal Step 2: Go to Personal Access Token Step 3: Create a Token by clicking on “New Token“ Give it a name Select the “Read” checkbox to fetch the repository Click on Create Note: Copy and Save the token as you will not be able to see it again Create a YAML Pipeline Step 1: Go to Pipelines Step 2: Choose Azure Repos Git Step 3: Select your repository Step 4: Configure it as a starter Pipeline Below is the default code you will see. Trigger: The wildcard (*) will monitor all the branches, the pipeline will be triggered whenever you have any changes in your repository CmdLine: The command calls “git clone –mirror ” to make a copy of your repository. PAT needed to be used while fetching a repository Archive Files: It will take the git repository which was cloned in the previous step and then zipped to “Backup.zip” File Copy: It will take the archive copy and send it to Azure Blob Storage Creating a Subscription Connection Step 1: Go to Project Settings Step 2: Go to Service connections Step 3: Click on New service connection Step 4: Choose Azure Resource Manager Step 5: Select Authentication Method as Service Principal (automatic) Note: Make sure to use the same credentials to login to DevOps as in Azure Portal Step 6: Subscription will be chosen automatically. Give it a name Select a resource group where you have your storage account Then save Step 7: Use the connection name in YAML. Save and Run It will create a Job See the status of the Job After Job gets completed, you will see a zip file in your blob

Share Story :

CI/CD Pipeline using YAML file

This is blog is intended to share information about creating a CI / CD Pipeline using YAML file. Case Study Create a CI/CD pipeline using YAML for a web application So, let’s start with lets creating a project Use cmd to create a project and then bind it to a solution Create Solution dotnet new sln -o Test_CI_CDPipeline Then change the directory cd Test_CI_CDPipeline Then create a Web Project inside Test_CI_CDPipeline dotnet new mvc -n Test_CI_CDPipeline Now bind the project to solution dotnet sln HelloWorldApp.sln add HelloWorldApp.Web\HelloWorldApp.Web.csproj Need to restore all the dependencies dotnet restore Now, build the solution. Do not restore dependencies while we are building the solution. dotnet build –no-restore –configuration release Publish the solution dotnet publish –no-build –configuration release. Now a project is created, built, and published on local Machine. The aim is to achieve the same using a continuous integration pipeline. For this one need to have an Azure DevOps account. In that, create an organization (if not created already) and then create a project. You can either create a private project or a public project. Before that, one needs to initialize git in the location machine. Go to the working folder (location of the location file). Initiate the git git init The purpose of git is to host the source code. Ensure that binaries created while building a project should not be included. For this add gitignore file to the project. Now, you need to stage all the content git add . Commit the content git commit -m “—Name-it—” Now you can push this to the Azure DevOps repo. Copy and paste the command and everything from the local machine will be pushed to Azure Repo. Create Pipeline Go to Pipelines on the Left panel and click on Create Pipeline. It gives two options YAML or Classic editor. Select Azure Repos Git (YAML) as it will be used to push the local project in further steps Select the project created earlier Select the type of project you are creating After this, you will see a YAML file. Here one needs to edit the file and make changes as per the need. Below is a sample code Trigger:  specifies which branches cause a continuous integration build to run Pool: specifies which pool to use for a job of the pipeline. A pool specification also holds information about the job’s strategy for running. Steps: specifies a list of tasks that need to be run Task: specifies commands/tasks that need to perform to achieve a build file. Build the project first Publish the Project Publish it as an Artifact Click save and run. Below shows the artifact created Now, this artifact needs to be consumed by an Azure website. For this, one needs to create a web application. Create an app service for that in the Azure portal. We need to create a service connection to connect Azure resource. Go to Project Setting, then service connections Create a New connection and select Azure Resource Manager Choose Automated (here you need to login with the same credentials that you use for the Azure portal) and click next Choose the subscription and Resource group. Give a name to the connection Now, proceed with creating a release pipeline Select the template you want to use and then apply. Choose the artifact from where you want the files to be picked up and click add Click on Job to a stage Add your Azure subscription, select the app service you have created, and save it. Then click on Create release Click on Deploy Once you are done deploying, click on the URL from the App service

Share Story :

SEARCH BLOGS:

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange