public sealed class AllocationPolicy : IMessage<AllocationPolicy>, IEquatable<AllocationPolicy>, IDeepCloneable<AllocationPolicy>, IBufferMessage, IMessage
Reference documentation and code samples for the Batch v1alpha API class AllocationPolicy.
A Job's resource allocation policy describes when, where, and how compute
resources should be allocated for the Job.
Labels applied to all VM instances and other resources
created by AllocationPolicy.
Labels could be user provided or system generated.
You can assign up to 64 labels. Google Compute Engine label
restrictions
apply.
Label names that start with "goog-" or "google-" are reserved.
public AllocationPolicy.Types.NetworkPolicy Network { get; set; }
The network policy.
If you define an instance template in the InstancePolicyOrTemplate field,
Batch will use the network settings in the instance template instead of
this field.
public ServiceAccount ServiceAccount { get; set; }
Defines the service account for Batch-created VMs. If omitted, the default
Compute Engine service
account
is used. Must match the service account specified in any used instance
template configured in the Batch job.
Includes the following fields:
email: The service account's email address. If not set, the default
Compute Engine service account is used.
scopes: Additional OAuth scopes to grant the service account, beyond the
default cloud-platform scope. (list of strings)
[[["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 \u003ccode\u003eAllocationPolicy\u003c/code\u003e class in the Batch v1alpha API defines how compute resources are allocated for a Job, including when, where, and how.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eAllocationPolicy\u003c/code\u003e class allows users to define the properties of instances created by the policy, such as location, network, placement, and labels.\u003c/p\u003e\n"],["\u003cp\u003eDeprecated fields like \u003ccode\u003eInstance\u003c/code\u003e, \u003ccode\u003eInstanceTemplates\u003c/code\u003e, \u003ccode\u003eProvisioningModels\u003c/code\u003e, and \u003ccode\u003eServiceAccountEmail\u003c/code\u003e should be replaced with the corresponding updated properties such as \u003ccode\u003eInstances\u003c/code\u003e and \u003ccode\u003eServiceAccount\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eUsers can apply up to 64 labels to VM instances and other resources, with restrictions on names starting with "goog-" or "google-".\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eInstances\u003c/code\u003e property is a core part of the \u003ccode\u003eAllocationPolicy\u003c/code\u003e, it is a \u003ccode\u003eRepeatedField\u003c/code\u003e that allows users to specify the details of the instances that will be created, although currently, only \u003ccode\u003einstances[0]\u003c/code\u003e is fully supported.\u003c/p\u003e\n"]]],[],null,["# Batch v1alpha API - Class AllocationPolicy (1.0.0-alpha31)\n\nVersion latestkeyboard_arrow_down\n\n- [1.0.0-alpha31 (latest)](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha.AllocationPolicy)\n- [1.0.0-alpha30](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/1.0.0-alpha30/Google.Cloud.Batch.V1Alpha.AllocationPolicy) \n\n public sealed class AllocationPolicy : IMessage\u003cAllocationPolicy\u003e, IEquatable\u003cAllocationPolicy\u003e, IDeepCloneable\u003cAllocationPolicy\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Batch v1alpha API class AllocationPolicy.\n\nA Job's resource allocation policy describes when, where, and how compute\nresources should be allocated for the Job. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e AllocationPolicy \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.V1Alpha/latest/Google.Cloud.Batch.V1Alpha.AllocationPolicy), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[AllocationPolicy](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha.AllocationPolicy), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[AllocationPolicy](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha.AllocationPolicy), [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.V1Alpha](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha)\n\nAssembly\n--------\n\nGoogle.Cloud.Batch.V1Alpha.dll\n\nConstructors\n------------\n\n### AllocationPolicy()\n\n public AllocationPolicy()\n\n### AllocationPolicy(AllocationPolicy)\n\n public AllocationPolicy(AllocationPolicy other)\n\nProperties\n----------\n\n### Instance\n\n [Obsolete]\n public AllocationPolicy.Types.InstancePolicy Instance { get; set; }\n\nDeprecated: please use instances\\[0\\].policy instead.\n\n### InstanceTemplates\n\n [Obsolete]\n public RepeatedField\u003cstring\u003e InstanceTemplates { get; }\n\nDeprecated: please use instances\\[0\\].template instead.\n\n### Instances\n\n public RepeatedField\u003cAllocationPolicy.Types.InstancePolicyOrTemplate\u003e Instances { get; }\n\nDescribe instances that can be created by this AllocationPolicy.\nOnly instances\\[0\\] is supported now.\n\n### Labels\n\n public MapField\u003cstring, string\u003e Labels { get; }\n\nLabels applied to all VM instances and other resources\ncreated by AllocationPolicy.\nLabels could be user provided or system generated.\nYou can assign up to 64 labels. [Google Compute Engine label\nrestrictions](https://cloud.google.com/compute/docs/labeling-resources#restrictions)\napply.\nLabel names that start with \"goog-\" or \"google-\" are reserved.\n\n### Location\n\n public AllocationPolicy.Types.LocationPolicy Location { get; set; }\n\nLocation where compute resources should be allocated for the Job.\n\n### Network\n\n public AllocationPolicy.Types.NetworkPolicy Network { get; set; }\n\nThe network policy.\n\nIf you define an instance template in the `InstancePolicyOrTemplate` field,\nBatch will use the network settings in the instance template instead of\nthis field.\n\n### Placement\n\n public AllocationPolicy.Types.PlacementPolicy Placement { get; set; }\n\nThe placement policy.\n\n### ProvisioningModels\n\n [Obsolete]\n public RepeatedField\u003cAllocationPolicy.Types.ProvisioningModel\u003e ProvisioningModels { get; }\n\nDeprecated: please use instances\\[0\\].policy.provisioning_model instead.\n\n### ServiceAccount\n\n public ServiceAccount ServiceAccount { get; set; }\n\nDefines the service account for Batch-created VMs. If omitted, the [default\nCompute Engine service\naccount](https://cloud.google.com/compute/docs/access/service-accounts#default_service_account)\nis used. Must match the service account specified in any used instance\ntemplate configured in the Batch job.\n\nIncludes the following fields:\n\n- email: The service account's email address. If not set, the default Compute Engine service account is used.\n- scopes: Additional OAuth scopes to grant the service account, beyond the default cloud-platform scope. (list of strings)\n\n### ServiceAccountEmail\n\n [Obsolete]\n public string ServiceAccountEmail { get; set; }\n\nDeprecated: please use service_account instead.\n\n### Tags\n\n public RepeatedField\u003cstring\u003e Tags { get; }\n\nOptional. Tags applied to the VM instances.\n\nThe tags identify valid sources or targets for network firewalls.\nEach tag must be 1-63 characters long, and comply with\n[RFC1035](https://www.ietf.org/rfc/rfc1035.txt)."]]