Azure DevOps Pipeline - YAML formatting error?

Solution 1:

Refer to the YAML documentation. You have a task (i.e. the first thing in the file) outside of a scope in which it's valid, which would be under steps.

The YAML editor does not guarantee syntactically valid YAML. You're better off using a more robust editor like Visual Studio Code with the Azure Pipelines extension.