Wednesday, October 19, 2022

Generate YAML from an Existing Azure DevOps Pipeline

Here's a quick tip if needing to generate a .yml file for CI/CD configuration from an existing Azure DevOps pipeline. There are several ways to build the .yml configuration file:

  • Make one from scratch
  • Use a template from GitHub or another similar project
  • Use the AzureDevOps pipeline editor and assistant
  • Use an auto-generated one created from a cloud portal (i.e. Azure portal)
However if the above solutions or any other aren't providing to be fruitful to your deployment configuration, you can leverage the classic editor from ADO to create a pipeline configuration visually via steps. This is often a means to an end to get working syntax in a methodical manner via form input, rather than through raw configuration.



Once you have a working pipeline however, it's ideal to get this configuration into your GitHub repository. This allows source control tracking on the configuration which is preferred to a pipeline used in a vacuum. If you used the classic editor to build a working pipeline, generating a .yml configuration is trivial. 

In ADO, navigate to the pipeline and find the ellipse next to, 'Run Pipeline.' From this menu you'll see an option to, 'Export to YAML.'


This will generate a .yml configuration file based on your working pipeline.


At this point you could add the .yml file to source control and create a new Azure pipeline connecting to your source control provider that leverages the newly created file.

Note different deployment systems use different YAML syntax or 'actions' so this may not be directly portable to another workflow for deployment. For example the .github/workflows directory in GitHub can connect to the repo from the Azure Portal in the Deployment configuration and use a .yml file. However the syntax is different for GitHub Actions, so the .yml file downloaded would only be a guide and require further massaging.



No comments:

Post a Comment