CLI 示例:创建并提交作业CLI example: Create and submit a job

媒体服务徽标 v3media services logo v3

在媒体服务 v3 中提交作业来处理视频时,必须告知媒体服务查找输入视频的位置。In Media Services v3, when you submit Jobs to process your videos, you have to tell Media Services where to find the input video. 其中一个选项是指定 HTTPS URL 作为作业输入(如本文中所示)。One of the options is to specify an HTTPS URL as a job input (as shown in this article).


创建媒体服务帐户Create a Media Services account.


可以在本地安装 CLI。You can install the CLI locally. 有关适用于你的平台的说明,请参阅安装 Azure CLISee Install the Azure CLI for instructions for your platform.

登录Sign in

使用本地安装的 CLI 需要登录到 Azure。Using a local install of the CLI requires signing in to Azure. 使用 az login 命令登录。Sign in with the az login command.

如果 CLI 可以打开默认的浏览器,则它会打开该浏览器并加载登录页。If the CLI can open your default browser, it will do so and load a sign-in page. 否则,你需要打开一个浏览器页面,在浏览器中导航到 后,按照有关命令行的说明输入授权代码。Otherwise, you need to open a browser page and follow the instructions on the command line to enter an authorization code after navigating to in your browser.

指定文件位置Specify location of files

许多媒体服务 CLI 命令允许你通过文件名来传递参数。Many Media Services CLI commands allow you to pass a parameter with a file name.

需要根据所用的 OS 或 Shell(Bash 或 PowerShell)指定文件路径。You need to specify the file path according to the OS or Shell (Bash or PowerShell) that you are using. 下面是一些示例:Below are some examples:

文件(所有 OS)的相对路径Relative path to the file (all OS)

  • @"mytestfile.json"
  • @"../mytestfile.json"

Linux/Mac 和 Windows OS 上的绝对文件路径Absolute file path on Linux/Mac and Windows OS

  • @ "/usr/home/mytestfile.json"
  • @"c:\tmp\user\mytestfile.json"

如果命令要求提供文件路径,请使用 {file}Use {file} if the command is asking for a path to the file. 例如,az ams transform create -a amsaccount -g resourceGroup -n custom --preset .\customPreset.jsonFor example, az ams transform create -a amsaccount -g resourceGroup -n custom --preset .\customPreset.json.
如果命令将加载指定的文件,请使用 @{file}Use @{file} if the command is going to load the specified file. 例如,az ams account-filter create -a amsaccount -g resourceGroup -n filterName --tracks @tracks.jsonFor example, az ams account-filter create -a amsaccount -g resourceGroup -n filterName --tracks @tracks.json.

示例脚本Example script

运行 az ams job start 时,可以在作业的输出上设置一个标签。When you run az ams job start, you can set a label on the job's output. 稍后可以使用此标签来标识该输出资产的用途。The label can later be used to identify what this output asset is for.

  • 如果为标签分配一个值,请将 ‘--output-assets’ 设置为 “assetname=label”If you assign a value to the label, set ‘--output-assets’ to “assetname=label”
  • 如果不为标签分配值,请将 ‘--output-assets’ 设置为 “assetname=”。If you do not assign a value to the label, set ‘--output-assets’ to “assetname=”. 请注意,你向 output-assets 添加了“=”。Notice that you add "=" to the output-assets.
az ams job start \
  --name testJob001 \
  --transform-name testEncodingTransform \
  --base-uri '' \
  --files 'Ignite-short.mp4' \
  --output-assets testOutputAssetName= \
  -a amsaccount \
  -g amsResourceGroup 

获取如下所示的响应:You get a response similar to this:

  "correlationData": {},
  "created": "2019-02-15T05:08:26.266104+00:00",
  "description": null,
  "id": "/subscriptions/<id>/resourceGroups/amsResourceGroup/providers/Microsoft.Media/mediaservices/amsaccount/transforms/testEncodingTransform/jobs/testJob001",
  "input": {
    "baseUri": "",
    "files": [
    "label": null,
    "odatatype": "#Microsoft.Media.JobInputHttp"
  "lastModified": "2019-02-15T05:08:26.266104+00:00",
  "name": "testJob001",
  "outputs": [
      "assetName": "testOutputAssetName",
      "error": null,
      "label": "",
      "odatatype": "#Microsoft.Media.JobOutputAsset",
      "progress": 0,
      "state": "Queued"
  "priority": "Normal",
  "resourceGroup": "amsResourceGroup",
  "state": "Queued",
  "type": "Microsoft.Media/mediaservices/transforms/jobs"

后续步骤Next steps

az ams job (CLI)az ams job (CLI)