Search code examples
azurevirtual-machineazure-cliazure-devtest-labs

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)


Solution

  • 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"""}]'