public sealed class AllocationPolicy.Types.InstancePolicyOrTemplate : IMessage<AllocationPolicy.Types.InstancePolicyOrTemplate>, IEquatable<AllocationPolicy.Types.InstancePolicyOrTemplate>, IDeepCloneable<AllocationPolicy.Types.InstancePolicyOrTemplate>, IBufferMessage, IMessage
Reference documentation and code samples for the Batch v1 API class AllocationPolicy.Types.InstancePolicyOrTemplate.
InstancePolicyOrTemplate lets you define the type of resources to use for
this job either with an InstancePolicy or an instance template.
If undefined, Batch picks the type of VM to use and doesn't include
optional VM resources such as GPUs and extra disks.
Optional. Set this field to true if you want Batch to block
project-level SSH keys from accessing this job's VMs. Alternatively, you
can configure the job to specify a VM instance template that blocks
project-level SSH keys. In either case, Batch blocks project-level SSH
keys while creating the VMs for this job.
Batch allows project-level SSH keys for a job's VMs only if all
the following are true:
This field is undefined or set to false.
The job's VM instance template (if any) doesn't block project-level
SSH keys.
Set this field true if you want Batch to help fetch drivers from a third
party location and install them for GPUs specified in
policy.accelerators or instance_template on your behalf. Default is
false.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe latest version of the \u003ccode\u003eAllocationPolicy.Types.InstancePolicyOrTemplate\u003c/code\u003e class is 2.13.0, with previous versions ranging from 2.12.0 down to 1.0.0 available for reference.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eInstancePolicyOrTemplate\u003c/code\u003e enables defining resource types for a job through an InstancePolicy or an instance template, and without any specification, it defaults to picking a VM type without optional resources.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eInstancePolicyOrTemplate\u003c/code\u003e class provides properties to manage project-level SSH key access, the automatic installation of GPU drivers, and the installation of the Ops Agent.\u003c/p\u003e\n"],["\u003cp\u003eThe class allows users to specify an instance template for creating VMs, supporting only global templates within the same project as the job.\u003c/p\u003e\n"],["\u003cp\u003eThis class implements interfaces such as \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, and inherits from \u003ccode\u003eobject\u003c/code\u003e, offering a suite of functionalities, including the ability to clone, compare and serialize instances.\u003c/p\u003e\n"]]],[],null,["# Batch v1 API - Class AllocationPolicy.Types.InstancePolicyOrTemplate (2.13.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.13.0 (latest)](/dotnet/docs/reference/Google.Cloud.Batch.V1/latest/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.12.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.12.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.11.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.11.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.10.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.10.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.9.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.9.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.8.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.8.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.7.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.7.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.6.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.6.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.5.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.5.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.4.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.3.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.2.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.2.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.1.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.1.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [2.0.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.0.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [1.3.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/1.3.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [1.2.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/1.2.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [1.1.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/1.1.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate)\n- [1.0.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/1.0.0/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate) \n\n public sealed class AllocationPolicy.Types.InstancePolicyOrTemplate : IMessage\u003cAllocationPolicy.Types.InstancePolicyOrTemplate\u003e, IEquatable\u003cAllocationPolicy.Types.InstancePolicyOrTemplate\u003e, IDeepCloneable\u003cAllocationPolicy.Types.InstancePolicyOrTemplate\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Batch v1 API class AllocationPolicy.Types.InstancePolicyOrTemplate.\n\nInstancePolicyOrTemplate lets you define the type of resources to use for\nthis job either with an InstancePolicy or an instance template.\nIf undefined, Batch picks the type of VM to use and doesn't include\noptional VM resources such as GPUs and extra disks. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e AllocationPolicy.Types.InstancePolicyOrTemplate \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[AllocationPolicy](/dotnet/docs/reference/Google.Cloud.Batch.V1/latest/Google.Cloud.Batch.V1.AllocationPolicy)[Types](/dotnet/docs/reference/Google.Cloud.Batch.V1/latest/Google.Cloud.Batch.V1.AllocationPolicy.Types)[InstancePolicyOrTemplate](/dotnet/docs/reference/Google.Cloud.Batch.V1/latest/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[AllocationPolicy](/dotnet/docs/reference/Google.Cloud.Batch.V1/latest/Google.Cloud.Batch.V1.AllocationPolicy)[Types](/dotnet/docs/reference/Google.Cloud.Batch.V1/latest/Google.Cloud.Batch.V1.AllocationPolicy.Types)[InstancePolicyOrTemplate](/dotnet/docs/reference/Google.Cloud.Batch.V1/latest/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[AllocationPolicy](/dotnet/docs/reference/Google.Cloud.Batch.V1/latest/Google.Cloud.Batch.V1.AllocationPolicy)[Types](/dotnet/docs/reference/Google.Cloud.Batch.V1/latest/Google.Cloud.Batch.V1.AllocationPolicy.Types)[InstancePolicyOrTemplate](/dotnet/docs/reference/Google.Cloud.Batch.V1/latest/Google.Cloud.Batch.V1.AllocationPolicy.Types.InstancePolicyOrTemplate), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Batch.V1](/dotnet/docs/reference/Google.Cloud.Batch.V1/latest/Google.Cloud.Batch.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Batch.V1.dll\n\nConstructors\n------------\n\n### InstancePolicyOrTemplate()\n\n public InstancePolicyOrTemplate()\n\n### InstancePolicyOrTemplate(InstancePolicyOrTemplate)\n\n public InstancePolicyOrTemplate(AllocationPolicy.Types.InstancePolicyOrTemplate other)\n\nProperties\n----------\n\n### BlockProjectSshKeys\n\n public bool BlockProjectSshKeys { get; set; }\n\nOptional. Set this field to `true` if you want Batch to block\nproject-level SSH keys from accessing this job's VMs. Alternatively, you\ncan configure the job to specify a VM instance template that blocks\nproject-level SSH keys. In either case, Batch blocks project-level SSH\nkeys while creating the VMs for this job.\n\nBatch allows project-level SSH keys for a job's VMs only if all\nthe following are true:\n\n- This field is undefined or set to `false`.\n- The job's VM instance template (if any) doesn't block project-level SSH keys.\n\nNotably, you can override this behavior by manually updating a VM to\nblock or allow project-level SSH keys. For more information about\nblocking project-level SSH keys, see the Compute Engine documentation:\n\u003chttps://cloud.google.com/compute/docs/connect/restrict-ssh-keys#block-keys\u003e\n\n### HasInstanceTemplate\n\n public bool HasInstanceTemplate { get; }\n\nGets whether the \"instance_template\" field is set\n\n### InstallGpuDrivers\n\n public bool InstallGpuDrivers { get; set; }\n\nSet this field true if you want Batch to help fetch drivers from a third\nparty location and install them for GPUs specified in\n`policy.accelerators` or `instance_template` on your behalf. Default is\nfalse.\n\nFor Container-Optimized Image cases, Batch will install the\naccelerator driver following milestones of\n\u003chttps://cloud.google.com/container-optimized-os/docs/release-notes\u003e. For\nnon Container-Optimized Image cases, following\n\u003chttps://github.com/GoogleCloudPlatform/compute-gpu-installation/blob/main/linux/install_gpu_driver.py\u003e.\n\n### InstallOpsAgent\n\n public bool InstallOpsAgent { get; set; }\n\nOptional. Set this field true if you want Batch to install Ops Agent on\nyour behalf. Default is false.\n\n### InstanceTemplate\n\n public string InstanceTemplate { get; set; }\n\nName of an instance template used to create VMs.\nNamed the field as 'instance_template' instead of 'template' to avoid\nC++ keyword conflict.\n\nBatch only supports global instance templates from the same project as\nthe job.\nYou can specify the global instance template as a full or partial URL.\n\n### Policy\n\n public AllocationPolicy.Types.InstancePolicy Policy { get; set; }\n\nInstancePolicy.\n\n### PolicyTemplateCase\n\n public AllocationPolicy.Types.InstancePolicyOrTemplate.PolicyTemplateOneofCase PolicyTemplateCase { get; }"]]