Custom Image under AzureBatch ImageReference class not working

人走茶凉 提交于 2019-12-23 03:09:43

问题


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".

I am referring this link Azure Batch

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
                    }
                }

回答1:


You need to ensure you have met the prerequisites for custom images in Azure Batch:

  1. The ARM Image is in the same subscription and region as the Batch account.
  2. You are using Azure Active Directory to authenticate with the Batch service.


来源:https://stackoverflow.com/questions/52318586/custom-image-under-azurebatch-imagereference-class-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!