azure-pipelinescontinuous-deploymentazure-pipelines-yamlcicd

Why does Azure Pipelines say "The environment does not exist or has not been authorized for use"?


In Azure Pipelines YAML, you can specify an environment for a job to run in.

  jobs:
    - deployment: Deploy
      displayName: Deploy
      environment: $(environment)

Passing a new value to the pipeline should automatically create the Environment in DevOps.

Automatically created environment

However, I have recently gotten this error when attempting to deploy to a new environment:

Job Deploy: Environment [environment-name] could not be found. The environment does not exist or has not been authorized for use.

After I created the environment manually, the pipeline deployed successfully.

Is there any configuration or something I'm missing that would allow the environment to be created automatically?


Solution

  • I have same issue and according to documentation it's not possible to create Environment this way.

    If you are using runtime parameters for creating the environment, it will fail as these parameters are expanded at run time. Environment creation happens at compile time, so we have to use variables to create the environment.

    For more info please check here.