Introducing Managed RunCommand Artifacts

Joseph Calev

As most of you may know from the current Managed RunCommand documentation there are multiple ways your script may be specified.

  1. Through the Script parameter. You can inline your entire script in this manner, though we don’t recommend the practice if your script contains confidential information.
  2. Through the CommandId parameter, which may be one of the values specified in the documentation.
  3. Through the ScriptUri parameter, in which case RunCommand will download your script from this uri. To provide access, you may either provide a SAS uri or a managed identity.

However, what if your script uses various artifacts that also must be downloaded to the machine? Well, in the past it was necessary to call RunCommand are use some other technique to get those files on the machine. That process is now simplified.

Added to the properties for Managed RunCommand is “artifacts”. This is a collection containing artifacts with three properties. artifactUri – The uri from which to download the artifact. As with scriptUri, this may be a SAS uri or you may use managed identities fileName – This is the name to rename the file to after download. If you don’t supply a name we’ll use the entirely original names of “artifact0”, “artifact1” and so on. artifactManagedIdentity – This is the managed identity to use with the artifact. It follows the same syntax as elsewhere, where you may specify the clientId or objectId of the managed identity.

You may specify up to five artifacts besides the script. We’ll download these and place them in the same directory as the script. If one fails to download, the operation will fail.

Note that this functionality currently exists only through ARM templates or direct Rest API calls. Extra artifacts aren’t yet supported through Powershell and CLI and, as of this writing, Managed RunCommand is not supported via Portal – only the older Action RunCommand.

Below is an example of artifacts in an ARM template.

{
  "type": "Microsoft.Compute/virtualMachines/runCommands",
  "name": "[concat(parameters('linuxVmName'),'/linuxVmRunCommand')]",
  "apiVersion": "2019-12-01",
  "location": "[parameters('region')]",
  "properties": {
    "source": {
      "scriptUri": "[parameters('linuxScriptUri')]"
    },
    "parameters": [
      {
        "name": "[parameters('firstParameterName')]",
        "value": "[parameters('firstParameterValue')]"
      },
      {
        "name": "[parameters('secondParameterName')]",
        "value": "[parameters('secondParameterValue')]"
      }
    ],
    "artifacts": [
      {
        "artifactUri": "[parameters('firstArtifactUri')]",
        "fileName": "my_first_artifact"
      },
      {
        "artifactUri": "[parameters('secondArtifactUri')]",
        "fileName": "my_second_artifact"
      }
    ],
    "outputBlobUri": "[parameters('linuxVMOutputBlobUri')]",
    "errorBlobUri": "[parameters('linuxVMErrorBlobUri')]",
    "timeoutInSeconds": 20
  }
}

 

0 comments

Leave a comment

Feedback usabilla icon