• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Build Your First Azure Pipeline (YAML-based CI/CD)

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Now that you’ve seen how Azure DevOps works and what role pipelines play in the DevOps lifecycle, it’s time to get hands-on. In this blog, we’ll walk through creating a complete CI/CD pipeline using YAML in Azure Pipelines.

We’ll cover:

  • Creating a new Azure DevOps project
  • Connecting your Git repo
  • Writing your first YAML pipeline
  • Running and debugging your build

Let’s go step-by-step.

Step 1: Create a New Project in Azure DevOps

  1. Go to

    Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

    and sign in.
  2. Click on New Project.
  3. Enter project name (e.g., my-first-pipeline), select Private, and click Create.
Step 2: Push Code to Azure Repos (or Connect GitHub)


You can either:

  • Push your local project to the Azure Repo created automatically, OR
  • Connect an external GitHub repo (from Pipelines > New Pipeline > GitHub)

Make sure your repo has a basic project setup — for example, a Node.js or Python app with tests.

Step 3: Create Your First Pipeline

  1. Go to Pipelines > New Pipeline.

    Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



  2. Choose your source (Azure Repos Git or GitHub).

    Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



  3. Select your repository.

    Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



  4. Azure will try to auto-detect a starter pipeline. You can use it or paste your own.

    Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


Step 4: Write the YAML for CI


Here’s a basic CI pipeline for a Node.js project:


trigger:
branches:
include:
- main

pool:
vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
inputs:
versionSpec: '18.x'
displayName: 'Install Node.js'

- script: |
npm install
npm test
displayName: 'Install dependencies and run tests'

- script: npm run build
displayName: 'Build application'

For Python:


trigger:
branches:
include:
- main

pool:
vmImage: 'ubuntu-latest'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'

- script: |
pip install -r requirements.txt
pytest
displayName: 'Install deps and run tests'
Step 5: Run the Pipeline


Once committed, the pipeline will automatically run.

You’ll see:

  • Each step’s status (success/failure)
  • Logs for every command
  • Artifacts (if any) saved from the build
Step 6: Debug Failures

  • Use the logs tab to inspect each task output
  • Common issues: missing dependencies, wrong version, permission errors
Step 7: Add Deployment to Azure and Set Up an Azure Service Connection (Optional)


Before your pipeline can deploy to Azure resources, it needs a secure way to authenticate. Azure DevOps handles this using Service Connections.

To create one:

  1. Go to your Azure DevOps project
  2. Navigate to Project Settings > Service connections
  3. Click New service connection
  4. Choose Azure Resource Manager
  5. Select Service principal (automatic) (recommended)
  6. Choose your subscription and authorize access
  7. Give it a recognizable name (e.g., MyServiceConnection)

This connection will be referenced in your pipeline YAML to authorize deployments.


- task: AzureWebApp@1
inputs:
azureSubscription: 'MyServiceConnection'
appName: 'my-web-app'
package: '$(System.DefaultWorkingDirectory)/**/*.zip'
Best Practices

  • Use separate pipelines for CI (build/test) and CD (deploy)
  • Store your pipeline YAML in the root of your repo (azure-pipelines.yml)
  • Protect your main branch with build validation policies
  • Use variable groups and secrets via Azure Key Vault
What’s Next


In the next blog, we’ll look at using Terraform with Azure DevOps to provision infrastructure as code. We’ll start by writing a basic Terraform script to deploy a resource group, and run it from a pipeline.

From pipelines to infrastructure — this is where DevOps gets powerful.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу