Resposta de referência
There are two popular approaches on Azure:
- Using Azure DevOps Services (Azure Pipelines): Azure DevOps is Microsoft's integrated platform that includes Repos (Git), Pipelines (CI/CD), Boards, Artifacts, etc. An answer here could outline using Azure Pipelines:
- Push code to Azure Repos (or GitHub, which Azure Pipelines can also integrate with).
- Build pipeline: Use Azure Pipelines (YAML or classic) to build the application and run tests. Mention that Azure Pipelines has a hosted pool of build agents, and supports just about any language or platform. After building, produce an artifact or Docker image.
- Release pipeline: Azure Pipelines can then deploy. For example, if deploying to an Azure Web App or Azure Function, there are tasks to do that (or use ARM templates to deploy infra, then deploy app). If using containers, maybe push to Azure Container Registry and then deploy to Azure Kubernetes Service (AKS).
- Note that Azure Pipelines supports multi-stage YAML pipelines now, so CI and CD can be in one pipeline as code.
- Azure DevOps also supports approvals, gates, etc., for control.
- Using GitHub Actions: Microsoft now often pushes GitHub Actions for CI/CD (especially if code is on GitHub). It's good to mention that if appropriate. GitHub Actions can build and deploy to Azure resources using official Azure action plugins (e.g., Azure Web Apps deploy, Azure CLI actions, etc.).
- Other Azure services: Azure has some platform-specific deployment options too, like Azure App Service can do deployment slots and has a deployment center that integrates with GitHub/Azure DevOps. But the above two cover most cases.
So an answer might be: "On Azure, I've used Azure DevOps Pipelines to set up CI/CD. For instance, we had a .NET Core web app – our Azure Pipelines YAML was triggered on any push to main. It would restore NuGet packages, build the solution, run tests, and package the app. The pipeline then had a deploy stage that used an Azure Resource Manager (ARM) template to ensure the Azure infrastructure (an App Service and SQL Database) was in place, and then a task to deploy the new package to the Azure App Service. We utilized Azure DevOps's built-in tasks for this, which made it straightforward. Also, we leveraged Azure DevOps Artifacts to store build artifacts and Azure Key Vault integration to fetch secrets during the pipeline (like connection strings). Alternatively, I've set up CI/CD with GitHub Actions for an Azure project – GitHub Actions would build our Node.js app and use the Azure Web App Deploy action to push it to an Azure Web App. Both approaches achieved automated, reliable deployments on Azure."