【问题标题】:Unable to get environment variable in azure batch VM无法在 Azure 批处理 VM 中获取环境变量
【发布时间】:2021-10-13 21:10:55
【问题描述】:

这是我尝试从微软教程 herehere 创建的 Azure 批处理配置

我正在尝试定义环境变量here

                CloudPool pool = batchClient.PoolOperations.CreatePool(
                    poolId: PoolId,
                    targetDedicatedComputeNodes: PoolNodeCount,
                    virtualMachineSize: PoolVMSize,
                    virtualMachineConfiguration: vmConfiguration);

                // Specify the application and version to install on the compute nodes
                pool.ApplicationPackageReferences = new List<ApplicationPackageReference>
                {
                    new ApplicationPackageReference {
                        ApplicationId = "7Zip",
                        Version = "19.00" }
                };

                // Commit the pool so that it's created in the Batch service. As the nodes join
                // the pool, the specified application package is installed on each.
                await pool.CommitAsync();


                    CloudJob job = batchClient.JobOperations.CreateJob();
                    job.Id = JobId;
                    job.PoolInformation = new PoolInformation { PoolId = PoolId };

                    await job.CommitAsync();
                    string taskId = "blendertask01";
                    string commandLine =
                        @"cmd /c echo %AZ_BATCH_APP_PACKAGE_7Zip%";
                    CloudTask blenderTask = new CloudTask(taskId, commandLine);
                    batchClient.JobOperations.AddTask(JobId, blenderTask);

我期待cmd /c echo %AZ_BATCH_APP_PACKAGE_7Zip% 的输出为我提供可以找到我的应用程序 7zip 的路径,以便我可以安装它,但我不明白。 相反,我得到%AZ_BATCH_APP_PACKAGE_7Zip%

【问题讨论】:

    标签: azure azure-batch


    【解决方案1】:

    我们应该指定版本而不是使用AZ_BATCH_APP_PACKAGE_7Zip 因此它会变成%AZ_BATCH_APP_PACKAGE_7Zip#19.00%\7z1900-x64.exe

    这个信息没有明确定义,但是经过几次点击和尝试后我发现了它

    另外,当我们使用远程帐户登录时,env 变量是不可见的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-13
      • 1970-01-01
      • 2012-03-19
      • 1970-01-01
      • 1970-01-01
      • 2021-10-19
      相关资源
      最近更新 更多