What's the purpose of azure-pipeline.yml - azure

I have read some tutorials about Azure DevOps. There are 3 things i do not really understand:
Can we say azure-pipeline.yml on Azure is the equivalent of .gitlab-ci.yml on gitlab ?
I have read some tutorials talking about azure-pipeline.yml files and others talking about azure-pipelines.yml ? What is the good syntax for this file name ?
I have create a "devops project" from Azure Services page. I have choose ASP.Net Core Application and Windows Web App. I can see a pipeline on dev.azure.com but there is no yml file in source code. So i am wondering where is this file...
Thanks

Can we say azure-pipeline.yml on Azure is the equivalent of .gitlab-ci.yml on gitlab
YAML defines the way to code your configuration management by defining build and release pipelines in the code.It is named as azure-pipelines in Azure Devops and .gitlab-ci.yml on gitlab
have read some tutorials talking about azure-pipeline.yml files and others talking about azure-pipelines.yml ? What is the good syntax for this file name ?
azure-pipelines.yml is the default name, but if you need you canhange the name of the yaml file by clicking on "Edit in the visual designer".
I have create a "devops project" from Azure Services page. I have choose ASP.Net Core Application and Windows Web App. I can see a pipeline on dev.azure.com but there is no yml file in source code. So i am wondering where is this file...
There are two ways to create the pipeline one is using the classic editor and using the YAML code. It should definitely be there if you create it using YAML

Answering your question in the same order they were asked.
Yes, azure-pipeline.yml is the equivalent of gitlab-ci.yml. In both cases you bundle together a number of commands you want to execute.
It is the same. The file is called azure-pipelines.yml. Good thing if you try to edit the file in azure-devops is that there is a really nice check and auto-completion tool, that helps a lot especially in indentation (spaces before the command)which is a common issue with yaml files.
If you created the Ci/CD pipelines by the development center in azure portal you see a UIed version of the yaml. But for every step you can still see the yaml code if you wish. If you try to create a new build pipeline the default way you get is to use the yaml file.

Related

Is there any way to do selective deployment in azure devops?

I have a release pipeline which i use to deploy my resources to other environments. All works fine but the problem is that every time i deploy, all the resources even if no modification is made, are deployed. Is there a way through which i can do selective deployment; i.e. I deploy only those resources which have been modified. Any help would do. Thanks.
That`s a broad question. There is no out-of-box feature to select units to deploy. But you can use variables in the release pipeline:
Define a variable for each resource/unit and set some default value and "Settable at release time" property.
For each resource, define a separate task to deploy and define the custom condition, like: and(succeeded(), eq(variables['Custom.DeployUnit1'], 'YES'))
You can update these variables at the release creation time:
Is there any way to do selective deployment in azure devops?
There is no such out of box way to selective deployment in azure devops.
That because Azure devops release does not support release only changed files since only release changed files not always meaningful and could not archive what the project intend to release (such as the config file only changed in a commit).
But you could create a PowerShell script to compare timestamp for all files:
Create XML file that stores the last upload/publish information of
each files (e.g. file name, date time, changeset/commit version).
Create a PowerShell script file that included the logical to compare
files (get files metadata and compare with that XML file) and copy
updated files to specific folder
Publish the files in that folder
Check the similar thread for some more details.
Besides, if deploying via the deploy.cmd or MSDeploy.exe, you could also use the the -useChecksum WebDeploy flag:
WebDeploy/MSDeploy Quick Tip: Only Deploy Changed Files
Hope this helps.

Azure functions - deploy by project in single repo?

We are building a set of serverless functions in Azure, but having difficulty deciding how to structure our source (Azure GIT) and DevOps to support them.
I am thinking of a single GIT repo, with all function apps housed independently within projects. We may have a lot of these function apps, we see great value in small code segments to do utility type of work, and I don't want dozens and dozens of independent repos just because of DevOps deployments. Is there a way to have a unique build and release process for each project, not the repo entirely? We aren't clear how this can be done and searches have come up empty on this. I thought it was possible to have unique build YAMLs per project across many projects in a single repo - but unclear how to implement the DevOps build and release pipleines to support this approach - ie; only a single function gets updated and we need to deploy - any guidance if this is possible and how to approach it would be great.
I haven't done this myself, but I'm in a similar situation where I'd like to have multiple functions (and other stuff) in a single Git repo for simplicity, but only build/deploy them as needed when they change. It looks like you can have multiple pipelines on a single repo with a different YAML file for each pipeline. The steps are documented in this link, and summarized below
In Azure DevOps, create a new Pipeline.
For the "Where is your code?" page, at the bottom choose the Use the classic editor option.
Select your source repo and branch.
On the "Select a template" screen, choose the YAML option at the top. Hit Apply.
There is a YAML file path field where you can specify the path and name of your YAML file for the pipeline.
You may want to set the pipeline to run manually if you don't want a build each time there's a commit to the repo.
EDIT There may be an easier way to do this now. If you go through the New Pipeline wizard, select your source location, on the Configure tab, at the bottom you can choose the Existing Azure Pipelines YAML file option. This lets you select a custom YAML file directly.

Convert visual build pipeline in yaml file

I'm working with Azure DevOps pipeline and I'm using the visual designer.
But there is also the YAML file. I would like to export my Build pipeline into a YAML file. It seems to be possible like mentionned in this Github issue (https://github.com/MicrosoftDocs/vsts-docs/issues/2504) using the View YAML button.
But this button is disable in my project (I cannot click on it):
I don't know how to enable it. The preview feature New YAML pipeline creation experience is enabled. I'm using some Task that are tagged as Preview. Can it be a reason?
Does someone know why it is disabled and how to enabled it?
I also have the same problem for several projects on pipeline level:
Try to check the agent level. It may be available:
FYI you will shortly be able to export the entire pipeline to YAML (the ability to export individual tasks will be removed);
https://devblogs.microsoft.com/devops/replacing-view-yaml/

Variable substitution in build pipeline

There are tons of resources online on how to replace JSON configuration files in a release pipeline like this one. I configured this. It works. However, we have multiple integration tests which reach the database too. These tests are run during build time. I haven't seen any option yet to replace config values in the build pipeline. Does it exist? Or do I really have to use this custom task (see screenshot below)?
There is an out-of-the-box task since recently by Microsoft. It's called File Transform. It's currently in preview but it works really well! Haven't had any issues whatsoever with it and it works the same as you would configure it in the release pipeline. Would recommend this any day!
Below you can see my configuration.
There is no out-of-the-box task only to replace tokens/values in files (also in the release pipline the task is Azure App Service Deploy and not only for replace json configuration).
You need to use an external extension from here or write a PowerShell script for that.

Setting the environment for XML transformation in an Azure App Service Deploy task

I'm using an Azure DevOps Pipeline to release an ASP.NET MVC system to an Azure Web App.
I've configured the build not to apply the XML transforms, so I can apply them later, during the release step, and the same build artefact can be released to multiple environments.
The build works fine, and I end up with an artefact containing an untransformed web.config, and the environment-specific transform files.
The Azure App Service Deploy task has a check-box called XML Transformation, which displays the following help text:
The config transforms will be run for *.Release.config and
*.<EnvironmentName>.config on the *.config file. Config transforms will be run prior to the Variable Substitution. XML transformations
are supported only for Windows platform.
At the moment I'm trying to set up a release into a test environment, but the Web.Release.config is being applied, rather than the Web.Test.config. I've searched everywhere I can find for a place to define the environment to make the release use the test config, but I can't find anywhere.
There's a similar question on GitHub which shows the following screenshot:
Unfortunately mine doesn't look like that:
Am I trying to do the right thing? If so, where do I set the environment?
You need to make sure your stage name is just 'Test' and not 'Deploy EMS to Test', reference here.

Resources