Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to install VSTS Agent using DSC. #24

Closed
mansing2 opened this issue May 12, 2020 · 1 comment
Closed

Failed to install VSTS Agent using DSC. #24

mansing2 opened this issue May 12, 2020 · 1 comment

Comments

@mansing2
Copy link

I'm trying to install Agent using DSC but getting an error. Below is the DSC definition I'm using for the local test but keep on failing with error "ConvertTo-MOFInstance : System.InvalidOperationException error processing property 'AccountCredential' OF TYPE 'xVSTSAgent': Converting and storing encrypted passwords as plain
text is not recommended. For more information on securing credentials in MOF file, please refer to MSDN blog: http://go.microsoft.com/fwlink/?LinkId=393729"

on the Azure side the error is "PowerShell DSC resource xVSTSAgent failed to execute Set-TargetResource functionality with error message: Could not find agent matching requirements."

My account that I use to login to DevOps (https://dev.azure.com/CO-Test) has MFA activated so not sure if that is the reason, it keeps on failing.

Configuration InstallVSTSAgent
{
     param 
    (   
        [parameter(Mandatory = $true)] 
        [PSCredential]$AccountCredential
    )
  
    Import-DSCResource -ModuleName 'VSTSAgent'
       
    xVSTSAgent VSTSAgent 
    {  
            Name              = 'Agent01'
            ServerUrl         = 'https://dev.azure.com/CO-Test'
            AccountCredential = $AccountCredential
            AgentDirectory    = 'C:\Agent'
            Work              = 'C:\VSTSAgentsWork\Agent01'
            Ensure            = 'Present' 
    }
}
  # Compile the configuration file to a MOF format
    InstallVSTSAgent

    # Run the configuration on localhost
    Start-DscConfiguration -Path .\InstallVSTSAgent -Wait -Force -Verbose```
@jwittner
Copy link
Member

Hey @mansing2 - thanks for trying out the VSTS Agent DSC tooling! This is a common problem when using credentials in DSC.

Your exact error and how to work around it are described here: Credential Options in Configuration Data.

If you're leveraging Azure Automation, this documentation covers how to use their Credential Assets and how to configure support for the credentials in DSC.

Both of the above methods direct you to allow plain text passwords (safe if you run the dsc locally and safe in Azure Automation as the entire mof is encrypted at rest and in transit). There are other resources out there for how to encrypt your credentials or the mof for transit, but I'll leave that googling to the reader. =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants