[英]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.