0

I have a PowerShell script and would like to use az lab vm -apply-artifacts to add the artifacts to VM. Could anyone please give me an example artifact Json file and how to call it from Azure CLI? Thanks a lot!

Swinkaran
  • 1,207
  • 1
  • 12
  • 19
Trung.Tr
  • 3
  • 1

2 Answers2

0

give me an example artifact Json file and how to call it from Azure CLI?

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": ""
  }
}

And you cuold get a sample artifacts.json definition file. Check out the artifacts created by the DevTest Labs team in GitHub repository.

Apply artifacts to a virtual machine in Azure DevTest Lab.

az lab vm apply-artifacts --artifacts '@artifacts.json' --lab-name MyLab --name MyVirtualMachine --resource-group MyResourceGroup
Joey Cai
  • 18,968
  • 1
  • 20
  • 30
  • Thanks, Joey! For example, I have three parameters in the artifact JSON. What is the "commandToExecute" that will look like? Where do/should I specify the values for parameters? In JSON file or from Azure CLI as arguments? What is the best practice and can you please give me an example of how to do it? – Trung.Tr Feb 19 '20 at 17:06
  • Like in this [sample](https://github.com/Azure/azure-devtestlab/blob/master/Artifacts/windows-chocolatey/Artifactfile.json), you could use` "commandToExecute": "[concat('powershell.exe -ExecutionPolicy bypass \"& ./install-choco-package.ps1 -Packages ''', parameters('packages'), ''' -AllowEmptyChecksums $', parameters('allowEmptyChecksums'), ' -IgnoreChecksums $', parameters('ignoreChecksums'), '\"')]" ` to specify the value for parameters. – Joey Cai Feb 26 '20 at 02:00
0

Use the following template:

[
    {
      "artifactId": "/artifactSources/public repo/artifacts/windows-chocolatey",
      "parameters": [
        {
          "name": "packages",
          "value": "sqlserver-odbcdriver"
        },
        {
          "name": "allowEmptyChecksums",
          "value": "true"
        },
        {
          "name": "ignoreChecksums",
          "value": "false"
        }
      ]
    }
]

Command:

az lab vm apply-artifacts --artifacts "@AddChocolateyArtifact.json" --lab-name "DTL_Name" --name "VM_Name" --resource-group "RG_Name"

Reference: https://github.com/Azure/azure-cli/issues/13267

A7med
  • 23
  • 6