Développement sur Azure
Discover the main Azure development services with practical examples.
Azure DevOps
Azure DevOps is a complete platform for software development.
Configuring a Project
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
# Create the connection
credentials = BasicAuthentication('', '<pat_token>')
connection = Connection(base_url='<organization_url>', creds=credentials)
client = connection.clients.get_core_client()
# Create a project
project = {
"name": "mon-projet",
"description": "Description du projet",
"capabilities": {
"versioncontrol": {
"sourceControlType": "Git"
},
"processTemplate": {
"templateTypeId": "6b724908-ef14-45cf-84f8-768b5384da45"
}
}
}
# Create the project
client.create_project(project)
Configuring a CI/CD Pipeline
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
Azure Repos for source code management.
Creating a Repository
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
# Create the connection
credentials = BasicAuthentication('', '<pat_token>')
connection = Connection(base_url='<organization_url>', creds=credentials)
client = connection.clients.get_git_client()
# Create a repository
repository = {
"name": "mon-repo",
"project": {
"id": "<project_id>"
}
}
# Create the repository
client.create_repository(repository)
Managing Branches
# Create a branch
branch = {
"name": "feature/nouvelle-fonctionnalite",
"oldObjectId": "<commit_id>",
"newObjectId": "<new_commit_id>"
}
# Create the branch
client.create_ref(
repository_id="<repo_id>",
ref=branch
)
# Create a pull request
pull_request = {
"sourceRefName": "refs/heads/feature/nouvelle-fonctionnalite",
"targetRefName": "refs/heads/main",
"title": "Nouvelle fonctionnalité",
"description": "Description des changements"
}
# Create the pull request
client.create_pull_request(
repository_id="<repo_id>",
pull_request=pull_request
)
Azure Artifacts
Azure Artifacts for package management.
Publishing a Package
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
# Create the connection
credentials = BasicAuthentication('', '<pat_token>')
connection = Connection(base_url='<organization_url>', creds=credentials)
client = connection.clients.get_packaging_client()
# Create a feed
feed = {
"name": "mon-feed",
"description": "Feed pour mes packages"
}
# Create the feed
client.create_feed(feed)
# Publish a package
package = {
"name": "mon-package",
"version": "1.0.0",
"description": "Description du package"
}
# Publish the package
client.create_package(
feed_id="<feed_id>",
package=package
)
Azure Boards
Azure Boards for project management.
Creating a Work Item
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
# Create the connection
credentials = BasicAuthentication('', '<pat_token>')
connection = Connection(base_url='<organization_url>', creds=credentials)
client = connection.clients.get_work_item_tracking_client()
# Create a work item
work_item = {
"op": "add",
"path": "/fields/System.Title",
"value": "Nouvelle tâche"
}
# Create the work item
client.create_work_item(
document=work_item,
project="mon-projet",
type="Task"
)
Azure Test Plans
Azure Test Plans for test management.
Creating a Test Plan
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
# Create the connection
credentials = BasicAuthentication('', '<pat_token>')
connection = Connection(base_url='<organization_url>', creds=credentials)
client = connection.clients.get_test_client()
# Create a test plan
test_plan = {
"name": "Plan de test",
"description": "Description du plan",
"startDate": "2024-03-22",
"endDate": "2024-04-22"
}
# Create the plan
client.create_test_plan(
test_plan=test_plan,
project="mon-projet"
)
Best Practices
-
Code Management
- Use Git Flow
- Conduct code reviews
- Maintain documentation
-
CI/CD
- Automate tests
- Use environments
- Manage secrets
-
Packages
- Version properly
- Maintain dependencies
- Secure feeds
-
Project
- Follow methodologies
- Use sprints
- Maintain the backlog
Conclusion
Key takeaways:
- Complete DevOps services
- Continuous integration
- Agile project management
- Good documentation
Recommendations:
- Start with Git
- Set up CI/CD
- Use sprints
- Follow best practices
- Train on Microsoft Learn
About InSkillCoach
Training and technology expert
Coach specializing in advanced technologies and AI, backed by GNeurone Inc.
Certifications:
- AWS Certified Solutions Architect – Professional
- Google Cloud certifications
- Microsoft Certified: DevOps Engineer Expert
- Certified Kubernetes Administrator (CKA)
- CompTIA Security+
1.7k
173
Comments
Comments are powered by GitHub Discussions
Sign in with GitHub to join the discussion