1
votes

I have a project on https://dev.azure.com. And I want to setup deploy to my virtual machine from master branch automatically. So, I read the this manual and did the following things:

  1. Create 'Production' environment
  2. Create new Resource for this environment
  3. Add new Virtual Machine as a Resource with VMenv name
  4. Run registration script on my virtual machine => here my VM was connected to Azure Devops
  5. Add tag Production to this resource
  6. Add the following step to my pipeline:
    - deployment: deploy
      displayName: Deploy to production
      environment:
          name:  VMenv
          resourceType: VirtualMachine
          tags: Production
      strategy:
        runOnce:
          deploy:
            steps:
              - script: echo This is deployment on production
                displayName: Deploy project
  1. And run this pipeline

And when I run this pipeline - it was stuck - here you can find details

Where I made mistake? How I can deploy on my virtual machine via azure devops?

1
Is there any update for this issue? Feel free to let me know if my answer helps to resolve your issue. Just a reminder of this .Kevin Lu-MSFT

1 Answers

2
votes

It seems that the deployment name field has known issues. If deployment:deploy , the job will be stuck.

I could reproduce this issue too.

For a workaround:

You could change the deployment field name(Except deploy).

The deployment name could contain A-Z, a-z, 0-9, and underscore.

For example:

jobs:  
- deployment: test
  displayName: Deploy to production
  environment:
    name:  VMenv
    resourceType: VirtualMachine
    tags: Production
  strategy:
    runOnce:
      deploy:
        steps:
          - script: echo This is deployment on production
            displayName: Deploy project

Then the pipeline job will run as expected.

Additional information:

In addition to using Environment:VirtualMachine for deployment, you can directly use self-hosted agent.

In this case, you could create the self-hosted agent on your Virtual Machine. Then you could directly use the self-hosted agent to deploy the resource to Virtual machine.

Hope this helps.