简体   繁体   English

如何使用托管标识删除 Azure 批处理池和作业?

[英]How to delete Azure Batch Pool and Jobs using Managed Identity?

Using C# I can delete Azure Batch Pools and Jobs using Client ID and Client Secret - but currently we want to delete them by using Azure Functions using Managed Identity.使用 C#,我可以使用客户端 ID 和客户端密码删除 Azure 批处理池和作业 - 但目前我们想通过使用托管身份的 Azure Functions 来删除它们。 Here is my current code:这是我当前的代码:

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();
    }
}

I see that in msdn social that there is no support for MSI currently in Azure Batch, so is there any alternative to just delete the Azure Batch Pools and Jobs?我在msdn social中看到 Azure Batch 目前不支持 MSI,那么有没有其他方法可以删除 Azure Batch 池和作业?

note: if it is not possible in C#, I am comfortable using Rest API or PowerShell also for deleting the pools and jobs of the batch account注意:如果在 C# 中不可能,我也很乐意使用 Rest API 或 PowerShell 删除批处理帐户的池和作业

2021-02-17 Updated Answer: 2021-02-17 更新答案:

Managed Identity on Batch pools is now in public preview in select regions. Batch 池上的托管标识现已在选定区域提供公共预览版。 Please see this doc .请参阅 此文档

Original Answer:原答案:

Managed Identity is not supported on Azure Batch compute nodes, however, you can use Managed Identities on other Azure resources that support it to authenticate with the Azure Batch resource provider. Azure Batch 计算节点不支持托管标识,但是,你可以在支持它的其他 Azure 资源上使用托管标识来向 Azure Batch 资源提供程序进行身份验证。 Please see this doc .请参阅此文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 对部署到 Azure 的应用程序使用 Azure 托管标识? - Using Azure Managed Identity for app deployed to Azure? 如何使用 C# 中的托管标识对 Azure 资源管理器进行身份验证 - How to authenticate with Azure Resource Manager using managed identity in C# 如何使用托管标识连接 Azure SQL DW - how to connect Azure SQL DW using Managed Identity using azure function Azure Function 函数如何使用托管标识获取对 Azure 表存储的引用? - How can an Azure Function function get a reference to Azure Table storage using Managed Identity? 在Azure函数中使用Azure Fluent SDK时,如何使用托管服务标识创建azure对象? - When using the Azure Fluent SDK in an Azure Function how can I create an azure object using a Managed Service Identity? 如何将 Azure 托管标识与 Azure.Storage.Blobs.BlobServiceClient 一起使用? - How to use Azure managed identity with Azure.Storage.Blobs.BlobServiceClient? Azure 存储帐户使用托管标识和 C# 进行身份验证 - Azure Storage Account authenticate using Managed Identity and C# 将 Azure 托管标识用于未授权新 SDK 的应用服务 - Using Azure managed identity for App Service not authorising for new SDK 使用托管标识从 Azure 应用服务调用图 - Call Graph from Azure App Service using Managed Identity 如何在 C# 中使用 REST API 获取 Azure 批处理池和作业列表? - How to get list of Azure Batch Pools and Jobs using REST API in C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM