Desenvolvimento no Azure
Descubra os principais serviços de desenvolvimento do Azure com exemplos práticos.
Azure DevOps
O Azure DevOps é uma plataforma completa para desenvolvimento de software.
Configuração de um projeto
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
# Criar a conexão
credentials = BasicAuthentication('', '<pat_token>')
connection = Connection(base_url='<organization_url>', creds=credentials)
client = connection.clients.get_core_client()
# Criar um projeto
project = {
"name": "mon-projet",
"description": "Description du projet",
"capabilities": {
"versioncontrol": {
"sourceControlType": "Git"
},
"processTemplate": {
"templateTypeId": "6b724908-ef14-45cf-84f8-768b5384da45"
}
}
}
# Criar o projeto
client.create_project(project)
Configuração de um pipeline CI/CD
trigger:
branches:
include:
- main
paths:
include:
- src/*
- tests/*
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
addToPath: true
- script: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python -m pytest tests/
displayName: 'Install dependencies and run tests'
- task: AzureWebApp@1
inputs:
azureSubscription: 'mon-connection'
appName: 'mon-app'
package: '$(System.DefaultWorkingDirectory)/src'
Azure Repos
O Azure Repos para o gerenciamento do código-fonte.
Criação de um repositório
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
# Criar a conexão
credentials = BasicAuthentication('', '<pat_token>')
connection = Connection(base_url='<organization_url>', creds=credentials)
client = connection.clients.get_git_client()
# Criar um repositório
repository = {
"name": "mon-repo",
"project": {
"id": "<project_id>"
}
}
# Criar o repositório
client.create_repository(repository)
Gerenciamento de branches
# Criar uma branch
branch = {
"name": "feature/nouvelle-fonctionnalite",
"oldObjectId": "<commit_id>",
"newObjectId": "<new_commit_id>"
}
# Criar a branch
client.create_ref(
repository_id="<repo_id>",
ref=branch
)
# Criar uma pull request
pull_request = {
"sourceRefName": "refs/heads/feature/nouvelle-fonctionnalite",
"targetRefName": "refs/heads/main",
"title": "Nouvelle fonctionnalité",
"description": "Description des changements"
}
# Criar a pull request
client.create_pull_request(
repository_id="<repo_id>",
pull_request=pull_request
)
Azure Artifacts
O Azure Artifacts para o gerenciamento de pacotes.
Publicação de um pacote
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
# Criar a conexão
credentials = BasicAuthentication('', '<pat_token>')
connection = Connection(base_url='<organization_url>', creds=credentials)
client = connection.clients.get_packaging_client()
# Criar um feed
feed = {
"name": "mon-feed",
"description": "Feed pour mes packages"
}
# Criar o feed
client.create_feed(feed)
# Publicar um pacote
package = {
"name": "mon-package",
"version": "1.0.0",
"description": "Description du package"
}
# Publicar o pacote
client.create_package(
feed_id="<feed_id>",
package=package
)
Azure Boards
O Azure Boards para o gerenciamento de projetos.
Criação de um work item
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
# Criar a conexão
credentials = BasicAuthentication('', '<pat_token>')
connection = Connection(base_url='<organization_url>', creds=credentials)
client = connection.clients.get_work_item_tracking_client()
# Criar um work item
work_item = {
"op": "add",
"path": "/fields/System.Title",
"value": "Nouvelle tâche"
}
# Criar o work item
client.create_work_item(
document=work_item,
project="mon-projet",
type="Task"
)
Azure Test Plans
O Azure Test Plans para o gerenciamento de testes.
Criação de um plano de teste
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
# Criar a conexão
credentials = BasicAuthentication('', '<pat_token>')
connection = Connection(base_url='<organization_url>', creds=credentials)
client = connection.clients.get_test_client()
# Criar um plano de teste
test_plan = {
"name": "Plan de test",
"description": "Description du plan",
"startDate": "2024-03-22",
"endDate": "2024-04-22"
}
# Criar o plano
client.create_test_plan(
test_plan=test_plan,
project="mon-projet"
)
Boas Práticas
-
Gerenciamento do Código
- Utilizar Git Flow
- Fazer revisões de código
- Manter uma documentação
-
CI/CD
- Automatizar os testes
- Utilizar ambientes
- Gerenciar os segredos
-
Pacotes
- Versionar corretamente
- Manter as dependências
- Proteger os feeds
-
Projeto
- Seguir as metodologias
- Utilizar as sprints
- Manter o backlog
Conclusão
Pontos-chave a reter:
- Serviços DevOps completos
- Integração contínua
- Gerenciamento ágil de projetos
- Boa documentação
Recomendações:
- Começar pelo Git
- Implantar CI/CD
- Utilizar as sprints
- Seguir as boas práticas
- Estudar no Microsoft Learn
Sobre InSkillCoach
Especialista em treinamento e tecnologias
Coach especializado em tecnologias avançadas e IA, apoiado pela GNeurone Inc.
Certificações:
- AWS Certified Solutions Architect – Professional
- Certificações Google Cloud
- Microsoft Certified: DevOps Engineer Expert
- Certified Kubernetes Administrator (CKA)
- CompTIA Security+
Comentários
Os comentários são alimentados pelo GitHub Discussions
Conecte-se com o GitHub para participar da discussão