public sealed class AllocationPolicy : IMessage<AllocationPolicy>, IEquatable<AllocationPolicy>, IDeepCloneable<AllocationPolicy>, IBufferMessage, IMessage
Reference documentation and code samples for the Batch v1 API class AllocationPolicy.
A Job's resource allocation policy describes when, where, and how compute
resources should be allocated for the Job.
Custom labels to apply to the job and all the Compute Engine resources
that both are created by this allocation policy and support labels.
Use labels to group and describe the resources they are applied to. Batch
automatically applies predefined labels and supports multiple labels
fields for each job, which each let you apply custom labels to various
resources. Label names that start with "goog-" or "google-" are
reserved for predefined labels. For more information about labels with
Batch, see
Organize resources using
labels.
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\u003eThis webpage provides documentation for the \u003ccode\u003eAllocationPolicy\u003c/code\u003e class within the Google Cloud Batch v1 API for .NET, detailing its use in managing resource allocation for jobs.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version of the \u003ccode\u003eAllocationPolicy\u003c/code\u003e is 2.13.0, and the page provides links to documentation for numerous previous versions, dating back to version 1.0.0.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eAllocationPolicy\u003c/code\u003e is a sealed class that inherits from \u003ccode\u003eobject\u003c/code\u003e and implements multiple interfaces, including \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe class's properties allow for the configuration of job instances, custom labels, compute resource location, network policies, placement strategies, service accounts, and VM instance tags.\u003c/p\u003e\n"],["\u003cp\u003eThe webpage details how to use \u003ccode\u003eAllocationPolicy\u003c/code\u003e to define when, where, and how compute resources are allocated, including the use of custom labels and the application of network firewalls.\u003c/p\u003e\n"]]],[],null,["# Batch v1 API - Class AllocationPolicy (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)\n- [2.12.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.12.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [2.11.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.11.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [2.10.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.10.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [2.9.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.9.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [2.8.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.8.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [2.7.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.7.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [2.6.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.6.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [2.5.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.5.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.4.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.3.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [2.2.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.2.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [2.1.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.1.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [2.0.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/2.0.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [1.3.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/1.3.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [1.2.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/1.2.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [1.1.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/1.1.0/Google.Cloud.Batch.V1.AllocationPolicy)\n- [1.0.0](/dotnet/docs/reference/Google.Cloud.Batch.V1/1.0.0/Google.Cloud.Batch.V1.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 v1 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.V1/latest/Google.Cloud.Batch.V1.AllocationPolicy), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[AllocationPolicy](/dotnet/docs/reference/Google.Cloud.Batch.V1/latest/Google.Cloud.Batch.V1.AllocationPolicy), [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), [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### AllocationPolicy()\n\n public AllocationPolicy()\n\n### AllocationPolicy(AllocationPolicy)\n\n public AllocationPolicy(AllocationPolicy other)\n\nProperties\n----------\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\nCustom labels to apply to the job and all the Compute Engine resources\nthat both are created by this allocation policy and support labels.\n\nUse labels to group and describe the resources they are applied to. Batch\nautomatically applies predefined labels and supports multiple `labels`\nfields for each job, which each let you apply custom labels to various\nresources. Label names that start with \"goog-\" or \"google-\" are\nreserved for predefined labels. For more information about labels with\nBatch, see\n[Organize resources using\nlabels](https://cloud.google.com/batch/docs/organize-resources-using-labels).\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### 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### 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)."]]