DasDave
DasDave

Reputation: 811

Create Azure VM with artifact switch

I'm trying to create a VM via the CLI and add an artifact from the public repo in a dev test lab.

Here is my script: az lab vm create --resource-group TestRG --lab-name TestLab --name 'ScriptVM' --image "Windows 10 Pro, Version 1809" --image-type gallery --size 'Standard_B2s' --admin-username 'user' --admin-password 'pw' --artifacts '{ "/artifactsources/publicrepo/artifacts/linux-java" }'

I don't know the format of the artifacts switch though as it just says a JSON encoded array. How does this work? I just get the error Expecting property name enclosed in double quotes: line 1 column 3 (char 2)

Upvotes: 0

Views: 131

Answers (2)

DasDave
DasDave

Reputation: 811

So the answer was I didn't have all the required elements in the JSON. I also fell foul of escaping quotation marks in the PS script. The final switch ended up looking like this:--artifacts '[{"""artifactId""": """artifacts/windows-notepadplusplus"""}]'

Upvotes: 1

Ken W - Zero Networks
Ken W - Zero Networks

Reputation: 3804

The following example shows the sections that make up the basic structure of a definition file:

{
  "$schema": "https://raw.githubusercontent.com/Azure/azure-devtestlab/master/schemas/2016-11-28/dtlArtifacts.json",
  "title": "",
  "description": "",
  "iconUri": "",
  "targetOsType": "",
  "parameters": {
    "<parameterName>": {
      "type": "",
      "displayName": "",
      "description": ""
    }
  },
  "runCommand": {
    "commandToExecute": ""
  }
}

It resides in your Git repo and is referenced in the AZ command. A video of the entire process can be found in our documentation.

https://learn.microsoft.com/en-us/azure/lab-services/devtest-lab-artifact-author

Upvotes: 0

Related Questions