AzureBatch ImageReference类下的自定义图像不起作用 [英] Custom Image under AzureBatch ImageReference class not working
本文介绍了AzureBatch ImageReference类下的自定义图像不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个自定义的VHD文件。我可以通过门户使用我的自定义映像创建Pool。但我想尝试与.Net SDK相同。但这会引发错误操作返回了无效的状态码禁止。
I have a custom VHD file with me. I am able to create Pool with my custom image through portal. But i want to try the same with .Net SDK. But it is throwing error "Operation returned an invalid status code 'Forbidden".
我指的是链接 Azure Batch
I am referring this link Azure Batch
我可以从MarketPlace图像创建池相同的代码
以下是我的代码
I am able to create Pool from MarketPlace images from same code Below is my code
ImageReference imageReference = new ImageReference("/subscriptions/XXXXXXXXXXXXXXX/resourceGroups/RG-OneGolden/providers/Microsoft.Compute/images/OMGoldenImage");
VirtualMachineConfiguration virtualMachineConfiguration =
new VirtualMachineConfiguration(
imageReference: imageReference,
nodeAgentSkuId: "batch.node.windows amd64");
try
{
CloudPool pool = batchClient.PoolOperations.CreatePool(
poolId: PoolId,
targetDedicatedComputeNodes: PoolNodeCount,
virtualMachineSize: PoolVMSize,
virtualMachineConfiguration: virtualMachineConfiguration);
pool.Commit();
}
catch (BatchException be)
{
// Accept the specific error code PoolExists as that is expected if the pool already exists
if (be.RequestInformation?.BatchError?.Code == BatchErrorCodeStrings.PoolExists)
{
Console.WriteLine("The pool {0} already existed when we tried to create it", PoolId);
}
else
{
throw; // Any other exception is unexpected
}
}
推荐答案
您需要确保已满足先决条件用于Azure批处理中的自定义映像:
You need to ensure you have met the prerequisites for custom images in Azure Batch:
- ARM映像与批处理帐户位于相同的订阅和区域中。
- 您正在使用Azure Active Directory对批处理服务进行身份验证。
这篇关于AzureBatch ImageReference类下的自定义图像不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文