【问题标题】:How to delete Azure Batch Pool and Jobs using Managed Identity?如何使用托管标识删除 Azure Batch Pool 和作业?
【发布时间】:2019-11-27 12:16:45
【问题描述】:

使用 C#,我可以使用客户端 ID 和客户端密钥删除 Azure Batch 池和作业 - 但目前我们希望通过使用托管标识的 Azure Functions 来删除它们。 这是我当前的代码:

internal async Task<string> GetAuthenticationTokenAsync()
{
    var authContext = new AuthenticationContext(AuthorityUri);
    var authResult = await authContext.AcquireTokenAsync(BatchResourceUri, new ClientCredential(BatchCredentials["ClientId"], BatchCredentials["ClientKey"])).ConfigureAwait(false);
    return authResult.AccessToken;
}

Task<string> TokenProvider() => GetAuthenticationTokenAsync();
using (var Batch = BatchClient.Open(new BatchTokenCredentials(BatchCredentials["BatchAccountURL"], TokenProvider)))
{
    var CloudPools = Batch.PoolOperations.ListPools();
    var JobList = Batch.JobOperations.ListJobs();
    foreach (var pool in CloudPools)
    {
        pool.DeleteAsync();
    }
    foreach (var job in JobList)
    {
        job.DeleteAsync();
    }
}

我在msdn social 中看到,Azure Batch 目前不支持 MSI,那么除了删除 Azure Batch 池和作业之外,还有其他选择吗?

注意:如果在 C# 中不可能,我也可以使用 Rest API 或 PowerShell 来删除批处理帐户的池和作业

【问题讨论】:

  • 你提到docs.microsoft.com/en-us/azure/batch/…了吗?它告诉我我们可以使用服务主体来管理 Azure 批处理资源(例如池、节点),并且 Managed Identity 也是一个服务主体。

标签: c# azure azure-functions azure-batch azure-managed-identity


【解决方案1】:

2021-02-17 更新答案:

批处理池上的托管标识现已在部分区域提供公共预览版。请参阅this doc

原答案:

Azure Batch 计算节点不支持托管标识,但是,您可以在其他支持它的 Azure 资源上使用托管标识向 Azure Batch 资源提供程序进行身份验证。请参阅this doc

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-11
    • 2020-05-02
    • 2020-07-03
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多