Azure批处理 - 为任务设置自定义用户标识

时间:2017-04-13 05:35:57

标签: azure-batch

我正在使用Azure Batch C#Client API 6.1。我正在尝试使用相同的用户身份进行所有运行。

我根据MSDN文档设置了如下自定义用户身份。

var task = new CloudTask("{guid}", "command string")
{
    DisplayName = "display name",
    UserIdentity = new UserIdentity("customUserid")
}

但是,当作业运行时,任务将在随机用户帐户下执行。

有人知道如何使其工作或即使后端Azure Batch服务支持它吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

In order to use named user accounts, you need to first specify a list of UserAccount on your CloudPool during creation.

pool.UserAccounts = new List<UserAccount>
{
    new UserAccount("myadminaccount", "adminpassword", ElevationLevel.Admin),
    new UserAccount("mynonadminaccount", "nonadminpassword", ElevationLevel.NonAdmin),
};

You will then be able to execute tasks assigned to this pool with UserIdentity properties as you have in your example.

Unfortunately the MSDN documentation for this feature is lagging behind currently, but should be updated soon.