diff --git a/src/Batch/Client/Src/Generated/ApplicationPackageReference.cs b/src/Batch/Client/Src/Generated/ApplicationPackageReference.cs
index 46d3ec202f69..8f2e6f14a587 100644
--- a/src/Batch/Client/Src/Generated/ApplicationPackageReference.cs
+++ b/src/Batch/Client/Src/Generated/ApplicationPackageReference.cs
@@ -10,7 +10,7 @@ namespace Microsoft.Azure.Batch
using System.Linq;
///
- /// A reference to an application package to be installed on compute nodes in a pool.
+ /// A reference to an application package to be deployed to compute nodes.
///
public partial class ApplicationPackageReference : ITransportObjectProvider, IPropertyMetadata
{
@@ -60,7 +60,7 @@ internal ApplicationPackageReference(Models.ApplicationPackageReference protocol
#region ApplicationPackageReference
///
- /// Gets or sets the id of the application to be installed on the compute nodes.
+ /// Gets or sets the id of the application to be deployed on compute nodes.
///
public string ApplicationId
{
@@ -69,10 +69,10 @@ public string ApplicationId
}
///
- /// Gets or sets the version of the application to be installed on the compute nodes.
+ /// Gets or sets the version of the application to be deployed on compute nodes.
///
///
- /// If not specified, the default version of the application, as defined in the application settings, is installed.
+ /// If not specified, the default version of the application, as defined in the application settings, is deployed.
/// If no default version is defined in the application settings, you must specify a version in the .
///
public string Version
diff --git a/src/Batch/Client/Src/Generated/CloudTask.cs b/src/Batch/Client/Src/Generated/CloudTask.cs
index 7e48e3de9962..1edbff3d0eac 100644
--- a/src/Batch/Client/Src/Generated/CloudTask.cs
+++ b/src/Batch/Client/Src/Generated/CloudTask.cs
@@ -18,6 +18,7 @@ public partial class CloudTask : ITransportObjectProvider AffinityInformationProperty;
+ public readonly PropertyAccessor> ApplicationPackageReferencesProperty;
public readonly PropertyAccessor CommandLineProperty;
public readonly PropertyAccessor ComputeNodeInformationProperty;
public readonly PropertyAccessor ConstraintsProperty;
@@ -44,6 +45,7 @@ private class PropertyContainer : PropertyCollection
public PropertyContainer() : base(BindingState.Unbound)
{
this.AffinityInformationProperty = this.CreatePropertyAccessor("AffinityInformation", BindingAccess.Read | BindingAccess.Write);
+ this.ApplicationPackageReferencesProperty = this.CreatePropertyAccessor>("ApplicationPackageReferences", BindingAccess.Read | BindingAccess.Write);
this.CommandLineProperty = this.CreatePropertyAccessor("CommandLine", BindingAccess.Read | BindingAccess.Write);
this.ComputeNodeInformationProperty = this.CreatePropertyAccessor("ComputeNodeInformation", BindingAccess.None);
this.ConstraintsProperty = this.CreatePropertyAccessor("Constraints", BindingAccess.Read | BindingAccess.Write);
@@ -74,6 +76,10 @@ public PropertyContainer(Models.CloudTask protocolObject) : base(BindingState.Bo
UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.AffinityInfo, o => new AffinityInformation(o).Freeze()),
"AffinityInformation",
BindingAccess.Read);
+ this.ApplicationPackageReferencesProperty = this.CreatePropertyAccessor(
+ ApplicationPackageReference.ConvertFromProtocolCollectionAndFreeze(protocolObject.ApplicationPackageReferences),
+ "ApplicationPackageReferences",
+ BindingAccess.Read);
this.CommandLineProperty = this.CreatePropertyAccessor(
protocolObject.CommandLine,
"CommandLine",
@@ -218,6 +224,19 @@ public AffinityInformation AffinityInformation
set { this.propertyContainer.AffinityInformationProperty.Value = value; }
}
+ ///
+ /// Gets or sets a list of application packages that the Batch service will deploy to the compute node before running
+ /// the command line.
+ ///
+ public IList ApplicationPackageReferences
+ {
+ get { return this.propertyContainer.ApplicationPackageReferencesProperty.Value; }
+ set
+ {
+ this.propertyContainer.ApplicationPackageReferencesProperty.Value = ConcurrentChangeTrackedModifiableList.TransformEnumerableToConcurrentModifiableList(value);
+ }
+ }
+
///
/// Gets or sets the command line of the task.
///
@@ -464,6 +483,7 @@ bool IReadOnly.IsReadOnly
Models.TaskAddParameter result = new Models.TaskAddParameter()
{
AffinityInfo = UtilitiesInternal.CreateObjectWithNullCheck(this.AffinityInformation, (o) => o.GetTransportObject()),
+ ApplicationPackageReferences = UtilitiesInternal.ConvertToProtocolCollection(this.ApplicationPackageReferences),
CommandLine = this.CommandLine,
Constraints = UtilitiesInternal.CreateObjectWithNullCheck(this.Constraints, (o) => o.GetTransportObject()),
DependsOn = UtilitiesInternal.CreateObjectWithNullCheck(this.DependsOn, (o) => o.GetTransportObject()),
diff --git a/src/Batch/Client/Src/Generated/JobManagerTask.cs b/src/Batch/Client/Src/Generated/JobManagerTask.cs
index cbb1f10fbe24..797275982732 100644
--- a/src/Batch/Client/Src/Generated/JobManagerTask.cs
+++ b/src/Batch/Client/Src/Generated/JobManagerTask.cs
@@ -16,6 +16,7 @@ public partial class JobManagerTask : ITransportObjectProvider> ApplicationPackageReferencesProperty;
public readonly PropertyAccessor CommandLineProperty;
public readonly PropertyAccessor ConstraintsProperty;
public readonly PropertyAccessor DisplayNameProperty;
@@ -28,6 +29,7 @@ private class PropertyContainer : PropertyCollection
public PropertyContainer() : base(BindingState.Unbound)
{
+ this.ApplicationPackageReferencesProperty = this.CreatePropertyAccessor>("ApplicationPackageReferences", BindingAccess.Read | BindingAccess.Write);
this.CommandLineProperty = this.CreatePropertyAccessor("CommandLine", BindingAccess.Read | BindingAccess.Write);
this.ConstraintsProperty = this.CreatePropertyAccessor("Constraints", BindingAccess.Read | BindingAccess.Write);
this.DisplayNameProperty = this.CreatePropertyAccessor("DisplayName", BindingAccess.Read | BindingAccess.Write);
@@ -41,6 +43,10 @@ public PropertyContainer() : base(BindingState.Unbound)
public PropertyContainer(Models.JobManagerTask protocolObject) : base(BindingState.Bound)
{
+ this.ApplicationPackageReferencesProperty = this.CreatePropertyAccessor(
+ ApplicationPackageReference.ConvertFromProtocolCollectionAndFreeze(protocolObject.ApplicationPackageReferences),
+ "ApplicationPackageReferences",
+ BindingAccess.Read);
this.CommandLineProperty = this.CreatePropertyAccessor(
protocolObject.CommandLine,
"CommandLine",
@@ -107,6 +113,19 @@ internal JobManagerTask(Models.JobManagerTask protocolObject)
#region JobManagerTask
+ ///
+ /// Gets or sets a list of application packages that the Batch service will deploy to the compute node before running
+ /// the command line.
+ ///
+ public IList ApplicationPackageReferences
+ {
+ get { return this.propertyContainer.ApplicationPackageReferencesProperty.Value; }
+ set
+ {
+ this.propertyContainer.ApplicationPackageReferencesProperty.Value = ConcurrentChangeTrackedModifiableList.TransformEnumerableToConcurrentModifiableList(value);
+ }
+ }
+
///
/// Gets or sets the command line of the task.
///
@@ -227,6 +246,7 @@ bool IReadOnly.IsReadOnly
{
Models.JobManagerTask result = new Models.JobManagerTask()
{
+ ApplicationPackageReferences = UtilitiesInternal.ConvertToProtocolCollection(this.ApplicationPackageReferences),
CommandLine = this.CommandLine,
Constraints = UtilitiesInternal.CreateObjectWithNullCheck(this.Constraints, (o) => o.GetTransportObject()),
DisplayName = this.DisplayName,
diff --git a/src/Batch/Client/Src/GeneratedProtocol/Models/ApplicationPackageReference.cs b/src/Batch/Client/Src/GeneratedProtocol/Models/ApplicationPackageReference.cs
index d224c4dece18..588421a9b4c5 100644
--- a/src/Batch/Client/Src/GeneratedProtocol/Models/ApplicationPackageReference.cs
+++ b/src/Batch/Client/Src/GeneratedProtocol/Models/ApplicationPackageReference.cs
@@ -27,8 +27,7 @@ namespace Microsoft.Azure.Batch.Protocol.Models
using Microsoft.Rest.Azure;
///
- /// A reference to an application package to be installed on compute nodes
- /// in a pool.
+ /// A reference to an application package to be deployed to compute nodes.
///
public partial class ApplicationPackageReference
{
@@ -42,8 +41,8 @@ public ApplicationPackageReference() { }
/// Initializes a new instance of the ApplicationPackageReference
/// class.
///
- /// The id of the application to install.
- /// The version of the application to install. If omitted, the default version is installed.
+ /// The id of the application to deploy.
+ /// The version of the application to deploy. If omitted, the default version is deployed.
public ApplicationPackageReference(string applicationId, string version = default(string))
{
ApplicationId = applicationId;
@@ -51,14 +50,14 @@ public ApplicationPackageReference() { }
}
///
- /// Gets or sets the id of the application to install.
+ /// Gets or sets the id of the application to deploy.
///
[JsonProperty(PropertyName = "applicationId")]
public string ApplicationId { get; set; }
///
- /// Gets or sets the version of the application to install. If
- /// omitted, the default version is installed.
+ /// Gets or sets the version of the application to deploy. If omitted,
+ /// the default version is deployed.
///
[JsonProperty(PropertyName = "version")]
public string Version { get; set; }
diff --git a/src/Batch/Client/Src/GeneratedProtocol/Models/CloudTask.cs b/src/Batch/Client/Src/GeneratedProtocol/Models/CloudTask.cs
index cc30c7d54677..9ce2c661d2e9 100644
--- a/src/Batch/Client/Src/GeneratedProtocol/Models/CloudTask.cs
+++ b/src/Batch/Client/Src/GeneratedProtocol/Models/CloudTask.cs
@@ -61,7 +61,8 @@ public CloudTask() { }
/// Information about how to run the multi-instance task.
/// Resource usage statistics for the task.
/// Any dependencies this task has.
- public CloudTask(string id = default(string), string displayName = default(string), string url = default(string), string eTag = default(string), DateTime? lastModified = default(DateTime?), DateTime? creationTime = default(DateTime?), ExitConditions exitConditions = default(ExitConditions), TaskState? state = default(TaskState?), DateTime? stateTransitionTime = default(DateTime?), TaskState? previousState = default(TaskState?), DateTime? previousStateTransitionTime = default(DateTime?), string commandLine = default(string), IList resourceFiles = default(IList), IList environmentSettings = default(IList), AffinityInformation affinityInfo = default(AffinityInformation), TaskConstraints constraints = default(TaskConstraints), bool? runElevated = default(bool?), TaskExecutionInformation executionInfo = default(TaskExecutionInformation), ComputeNodeInformation nodeInfo = default(ComputeNodeInformation), MultiInstanceSettings multiInstanceSettings = default(MultiInstanceSettings), TaskStatistics stats = default(TaskStatistics), TaskDependencies dependsOn = default(TaskDependencies))
+ /// A list of application packages that the Batch service will deploy to the compute node before running the command line.
+ public CloudTask(string id = default(string), string displayName = default(string), string url = default(string), string eTag = default(string), DateTime? lastModified = default(DateTime?), DateTime? creationTime = default(DateTime?), ExitConditions exitConditions = default(ExitConditions), TaskState? state = default(TaskState?), DateTime? stateTransitionTime = default(DateTime?), TaskState? previousState = default(TaskState?), DateTime? previousStateTransitionTime = default(DateTime?), string commandLine = default(string), IList resourceFiles = default(IList), IList environmentSettings = default(IList), AffinityInformation affinityInfo = default(AffinityInformation), TaskConstraints constraints = default(TaskConstraints), bool? runElevated = default(bool?), TaskExecutionInformation executionInfo = default(TaskExecutionInformation), ComputeNodeInformation nodeInfo = default(ComputeNodeInformation), MultiInstanceSettings multiInstanceSettings = default(MultiInstanceSettings), TaskStatistics stats = default(TaskStatistics), TaskDependencies dependsOn = default(TaskDependencies), IList applicationPackageReferences = default(IList))
{
Id = id;
DisplayName = displayName;
@@ -85,6 +86,7 @@ public CloudTask() { }
MultiInstanceSettings = multiInstanceSettings;
Stats = stats;
DependsOn = dependsOn;
+ ApplicationPackageReferences = applicationPackageReferences;
}
///
@@ -257,6 +259,13 @@ public CloudTask() { }
[JsonProperty(PropertyName = "dependsOn")]
public TaskDependencies DependsOn { get; set; }
+ ///
+ /// Gets or sets a list of application packages that the Batch service
+ /// will deploy to the compute node before running the command line.
+ ///
+ [JsonProperty(PropertyName = "applicationPackageReferences")]
+ public IList ApplicationPackageReferences { get; set; }
+
///
/// Validate the object.
///
@@ -301,6 +310,16 @@ public virtual void Validate()
{
this.Stats.Validate();
}
+ if (this.ApplicationPackageReferences != null)
+ {
+ foreach (var element2 in this.ApplicationPackageReferences)
+ {
+ if (element2 != null)
+ {
+ element2.Validate();
+ }
+ }
+ }
}
}
}
diff --git a/src/Batch/Client/Src/GeneratedProtocol/Models/JobManagerTask.cs b/src/Batch/Client/Src/GeneratedProtocol/Models/JobManagerTask.cs
index b79844e8cdfe..c73bf337de3d 100644
--- a/src/Batch/Client/Src/GeneratedProtocol/Models/JobManagerTask.cs
+++ b/src/Batch/Client/Src/GeneratedProtocol/Models/JobManagerTask.cs
@@ -48,7 +48,8 @@ public JobManagerTask() { }
/// Whether completion of the Job Manager task signifies completion of the entire job.
/// Whether to run the Job Manager task in elevated mode. The default value is false.
/// Whether the Job Manager task requires exclusive use of the compute node where it runs.
- public JobManagerTask(string id, string commandLine, string displayName = default(string), IList resourceFiles = default(IList), IList environmentSettings = default(IList), TaskConstraints constraints = default(TaskConstraints), bool? killJobOnCompletion = default(bool?), bool? runElevated = default(bool?), bool? runExclusive = default(bool?))
+ /// A list of application packages that the Batch service will deploy to the compute node before running the command line.
+ public JobManagerTask(string id, string commandLine, string displayName = default(string), IList resourceFiles = default(IList), IList environmentSettings = default(IList), TaskConstraints constraints = default(TaskConstraints), bool? killJobOnCompletion = default(bool?), bool? runElevated = default(bool?), bool? runExclusive = default(bool?), IList applicationPackageReferences = default(IList))
{
Id = id;
DisplayName = displayName;
@@ -59,6 +60,7 @@ public JobManagerTask() { }
KillJobOnCompletion = killJobOnCompletion;
RunElevated = runElevated;
RunExclusive = runExclusive;
+ ApplicationPackageReferences = applicationPackageReferences;
}
///
@@ -136,6 +138,13 @@ public JobManagerTask() { }
[JsonProperty(PropertyName = "runExclusive")]
public bool? RunExclusive { get; set; }
+ ///
+ /// Gets or sets a list of application packages that the Batch service
+ /// will deploy to the compute node before running the command line.
+ ///
+ [JsonProperty(PropertyName = "applicationPackageReferences")]
+ public IList ApplicationPackageReferences { get; set; }
+
///
/// Validate the object.
///
@@ -172,6 +181,16 @@ public virtual void Validate()
}
}
}
+ if (this.ApplicationPackageReferences != null)
+ {
+ foreach (var element2 in this.ApplicationPackageReferences)
+ {
+ if (element2 != null)
+ {
+ element2.Validate();
+ }
+ }
+ }
}
}
}
diff --git a/src/Batch/Client/Src/GeneratedProtocol/Models/TaskAddParameter.cs b/src/Batch/Client/Src/GeneratedProtocol/Models/TaskAddParameter.cs
index 744e859252b9..378b12898260 100644
--- a/src/Batch/Client/Src/GeneratedProtocol/Models/TaskAddParameter.cs
+++ b/src/Batch/Client/Src/GeneratedProtocol/Models/TaskAddParameter.cs
@@ -50,7 +50,8 @@ public TaskAddParameter() { }
/// Whether to run the task in elevated mode.
/// Information about how to run the multi-instance task.
/// Any other tasks that this task depends on.
- public TaskAddParameter(string id, string commandLine, string displayName = default(string), ExitConditions exitConditions = default(ExitConditions), IList resourceFiles = default(IList), IList environmentSettings = default(IList), AffinityInformation affinityInfo = default(AffinityInformation), TaskConstraints constraints = default(TaskConstraints), bool? runElevated = default(bool?), MultiInstanceSettings multiInstanceSettings = default(MultiInstanceSettings), TaskDependencies dependsOn = default(TaskDependencies))
+ /// A list of application packages that the Batch service will deploy to the compute node before running the command line.
+ public TaskAddParameter(string id, string commandLine, string displayName = default(string), ExitConditions exitConditions = default(ExitConditions), IList resourceFiles = default(IList), IList environmentSettings = default(IList), AffinityInformation affinityInfo = default(AffinityInformation), TaskConstraints constraints = default(TaskConstraints), bool? runElevated = default(bool?), MultiInstanceSettings multiInstanceSettings = default(MultiInstanceSettings), TaskDependencies dependsOn = default(TaskDependencies), IList applicationPackageReferences = default(IList))
{
Id = id;
DisplayName = displayName;
@@ -63,6 +64,7 @@ public TaskAddParameter() { }
RunElevated = runElevated;
MultiInstanceSettings = multiInstanceSettings;
DependsOn = dependsOn;
+ ApplicationPackageReferences = applicationPackageReferences;
}
///
@@ -155,6 +157,13 @@ public TaskAddParameter() { }
[JsonProperty(PropertyName = "dependsOn")]
public TaskDependencies DependsOn { get; set; }
+ ///
+ /// Gets or sets a list of application packages that the Batch service
+ /// will deploy to the compute node before running the command line.
+ ///
+ [JsonProperty(PropertyName = "applicationPackageReferences")]
+ public IList ApplicationPackageReferences { get; set; }
+
///
/// Validate the object.
///
@@ -199,6 +208,16 @@ public virtual void Validate()
{
this.MultiInstanceSettings.Validate();
}
+ if (this.ApplicationPackageReferences != null)
+ {
+ foreach (var element2 in this.ApplicationPackageReferences)
+ {
+ if (element2 != null)
+ {
+ element2.Validate();
+ }
+ }
+ }
}
}
}
diff --git a/src/Batch/Client/Tests/ObjectModel/Azure.Batch.Unit.Tests/ApplicationPackageReferencesUnitTests.cs b/src/Batch/Client/Tests/ObjectModel/Azure.Batch.Unit.Tests/ApplicationPackageReferencesUnitTests.cs
index 2d09e6e90c10..cf49d5af79f8 100644
--- a/src/Batch/Client/Tests/ObjectModel/Azure.Batch.Unit.Tests/ApplicationPackageReferencesUnitTests.cs
+++ b/src/Batch/Client/Tests/ObjectModel/Azure.Batch.Unit.Tests/ApplicationPackageReferencesUnitTests.cs
@@ -6,6 +6,7 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
+ using TestUtilities;
using BatchTestCommon;
using Microsoft.Azure.Batch;
using Microsoft.Azure.Batch.Auth;
@@ -327,6 +328,79 @@ public async Task GetJobScheduleWithApplicationPackageReferences()
}
}
+ [Fact]
+ [Trait(TestTraits.Duration.TraitName, TestTraits.Duration.Values.VeryShortDuration)]
+ public void CreateCloudTaskWithApplicationPackageReferences()
+ {
+ const string jobId = "id-123";
+ const string taskId = "id-123";
+ const string applicationId = "testApp";
+ const string applicationVersion = "beta";
+
+ using (BatchClient client = ClientUnitTestCommon.CreateDummyClient())
+ {
+ Models.CloudJob returnFakeJob = new Models.CloudJob(jobId);
+ var job = client.JobOperations.GetJob(jobId, additionalBehaviors: InterceptorFactory.CreateGetJobRequestInterceptor(returnFakeJob));
+
+ var verifyAPRs = ClientUnitTestCommon.SimulateServiceResponse>(
+ (parameters, options) =>
+ {
+ Assert.Equal(applicationId, parameters.ApplicationPackageReferences.First().ApplicationId);
+ Assert.Equal(applicationVersion, parameters.ApplicationPackageReferences.First().Version);
+
+ return new AzureOperationHeaderResponse
+ {
+ Response = new HttpResponseMessage(HttpStatusCode.Accepted)
+ };
+ });
+
+ var taskWithAPRs = new CloudTask(taskId, "cmd /c hostname")
+ {
+ ApplicationPackageReferences = new List
+ {
+ new ApplicationPackageReference
+ {
+ ApplicationId = applicationId,
+ Version = applicationVersion
+ }
+ }
+ };
+
+ job.AddTask(taskWithAPRs, additionalBehaviors: verifyAPRs); // assertions happen in the callback
+ }
+ }
+
+ [Fact]
+ [Trait(TestTraits.Duration.TraitName, TestTraits.Duration.Values.VeryShortDuration)]
+ public void GetJobManagerTaskWithApplicationPackageReferences()
+ {
+ const string jobId = "id-123";
+ const string applicationId = "foo";
+ const string version = "beta";
+
+ using (BatchClient client = ClientUnitTestCommon.CreateDummyClient())
+ {
+ Models.CloudJob protoJob = new Models.CloudJob
+ {
+ Id = jobId,
+ JobManagerTask = new Models.JobManagerTask
+ {
+ ApplicationPackageReferences = new List
+ {
+ new Models.ApplicationPackageReference
+ {
+ Version = version, ApplicationId = applicationId
+ }
+ }
+ }
+ };
+
+ var job = client.JobOperations.GetJob(jobId, additionalBehaviors: InterceptorFactory.CreateGetJobRequestInterceptor(protoJob));
+ Assert.Equal(applicationId, job.JobManagerTask.ApplicationPackageReferences.First().ApplicationId);
+ Assert.Equal(version, job.JobManagerTask.ApplicationPackageReferences.First().Version);
+ }
+ }
+
[Fact]
[Trait(TestTraits.Duration.TraitName, TestTraits.Duration.Values.VeryShortDuration)]
public void CheckIfGetApplicationPackageReferencesIsReadableButNotWritableOnABoundPool()
diff --git a/src/Batch/Client/Tests/ObjectModel/Azure.Batch.Unit.Tests/BindingStateConstraintUnitTests.cs b/src/Batch/Client/Tests/ObjectModel/Azure.Batch.Unit.Tests/BindingStateConstraintUnitTests.cs
index b06ff5009388..07d2150c97bf 100644
--- a/src/Batch/Client/Tests/ObjectModel/Azure.Batch.Unit.Tests/BindingStateConstraintUnitTests.cs
+++ b/src/Batch/Client/Tests/ObjectModel/Azure.Batch.Unit.Tests/BindingStateConstraintUnitTests.cs
@@ -43,7 +43,7 @@ public void Pool_WhenReturnedFromServer_HasExpectedUnboundProperties()
Assert.Equal(cloudPool.Metadata.First().Name, metadataItem.Name);
Assert.Equal(cloudPool.Metadata.First().Value, metadataItem.Value);
- cloudPool.Commit(additionalBehaviors: InterceptorFactory.CreateAddPoolRequestInterceptor() );
+ cloudPool.Commit(additionalBehaviors: InterceptorFactory.CreateAddPoolRequestInterceptor());
// writing isn't allowed for a cloudPool that is in an readonly state.
Assert.Throws(() => cloudPool.AutoScaleFormula = "Foo");
@@ -181,6 +181,8 @@ public void CloudJob_WhenSendingToTheServer_HasExpectedUnboundProperties()
const string displayName = "DisplayNameFoo";
MetadataItem metadataItem = new MetadataItem("foo", "bar");
const int priority = 0;
+ const string applicationId = "testApp";
+ const string applicationVersion = "beta";
BatchSharedKeyCredentials credentials = ClientUnitTestCommon.CreateDummySharedKeyCredential();
using (BatchClient client = BatchClient.Open(credentials))
@@ -190,9 +192,15 @@ public void CloudJob_WhenSendingToTheServer_HasExpectedUnboundProperties()
cloudJob.DisplayName = displayName;
cloudJob.Metadata = new List { metadataItem };
cloudJob.Priority = priority;
+ cloudJob.JobManagerTask = new JobManagerTask { ApplicationPackageReferences = new List
+ {
+ new ApplicationPackageReference { ApplicationId = applicationId, Version = applicationVersion }
+ }};
+
cloudJob.OnAllTasksComplete = OnAllTasksComplete.NoAction;
cloudJob.OnTaskFailure = OnTaskFailure.NoAction;
+
Assert.Throws(() => cloudJob.Url); // cannot read a Url since it's unbound at this point.
Assert.Equal(cloudJob.Id, jobId); // can set an unbound object
Assert.Equal(cloudJob.Metadata.First().Name, metadataItem.Name);
@@ -214,11 +222,15 @@ public void CloudJob_WhenReturnedFromServer_HasExpectedBoundProperties()
{
const string jobId = "id-123";
const string displayName = "DisplayNameFoo";
+ string applicationVersion = "beta";
+ string applicationId = "test";
+
MetadataItem metadataItem = new MetadataItem("foo", "bar");
const int priority = 0;
var onAllTasksComplete = OnAllTasksComplete.TerminateJob;
BatchSharedKeyCredentials credentials = ClientUnitTestCommon.CreateDummySharedKeyCredential();
+
using (BatchClient client = BatchClient.Open(credentials))
{
DateTime creationTime = DateTime.Now;
@@ -226,6 +238,10 @@ public void CloudJob_WhenReturnedFromServer_HasExpectedBoundProperties()
Models.CloudJob protoJob = new Models.CloudJob(
jobId,
displayName,
+ jobManagerTask: new Models.JobManagerTask()
+ {
+ ApplicationPackageReferences = new [] { new Models.ApplicationPackageReference(){ ApplicationId = applicationId, Version = applicationVersion } }
+ },
metadata: new[] { new Models.MetadataItem { Name = metadataItem.Name, Value = metadataItem.Value } },
creationTime: creationTime,
priority: priority,
@@ -234,21 +250,28 @@ public void CloudJob_WhenReturnedFromServer_HasExpectedBoundProperties()
CloudJob boundJob = client.JobOperations.GetJob(jobId, additionalBehaviors: InterceptorFactory.CreateGetJobRequestInterceptor(protoJob));
+
+
Assert.Equal(jobId, boundJob.Id); // reading is allowed from a job that is returned from the server.
Assert.Equal(creationTime, boundJob.CreationTime);
Assert.Equal(displayName, boundJob.DisplayName);
+ Assert.Equal(applicationId, boundJob.JobManagerTask.ApplicationPackageReferences.First().ApplicationId);
+ Assert.Equal(applicationVersion, boundJob.JobManagerTask.ApplicationPackageReferences.First().Version);
AssertPatchableJobPropertiesCanBeWritten(boundJob, priority, metadataItem, onAllTasksComplete);
// Can only read a url from a returned object.
Assert.Equal(ClientUnitTestCommon.DummyBaseUrl, boundJob.Url);
- // Cannot change a bound displayName and Id.
+ // Cannot change a bound displayName, Id and any property on a JobManagerTask.
Assert.Throws(() => boundJob.DisplayName = "cannot-change-display-name");
Assert.Throws(() => boundJob.Id = "cannot-change-id");
+ Assert.Throws(() => boundJob.JobManagerTask.ApplicationPackageReferences = new List());
+ Assert.Throws(() => boundJob.JobManagerTask = new JobManagerTask());
}
}
+
[Fact]
[Trait(TestTraits.Duration.TraitName, TestTraits.Duration.Values.VeryShortDuration)]
public void CloudTask_WhenReturnedFromServer_HasExpectedBoundProperties()
@@ -281,6 +304,7 @@ public void CloudTask_WhenReturnedFromServer_HasExpectedBoundProperties()
taskId,
additionalBehaviors: InterceptorFactory.CreateGetTaskRequestInterceptor(cloudTask));
+
Assert.Equal(taskId, boundTask.Id); // reading is allowed from a task that is returned from the server.
Assert.Equal(disableExitOption.JobAction.ToString(), boundTask.ExitConditions.Default.JobAction.ToString());
Assert.Throws(() => boundTask.ExitConditions = new ExitConditions());
diff --git a/src/Batch/Client/Tests/ObjectModel/Azure.Batch.Unit.Tests/TestUtilities/InterceptorFactory.cs b/src/Batch/Client/Tests/ObjectModel/Azure.Batch.Unit.Tests/TestUtilities/InterceptorFactory.cs
index a42a05c1d60d..ab0ffd188b42 100644
--- a/src/Batch/Client/Tests/ObjectModel/Azure.Batch.Unit.Tests/TestUtilities/InterceptorFactory.cs
+++ b/src/Batch/Client/Tests/ObjectModel/Azure.Batch.Unit.Tests/TestUtilities/InterceptorFactory.cs
@@ -21,7 +21,7 @@ public static class InterceptorFactory
Protocol.Models.JobAddOptions,
AzureOperationHeaderResponse>();
}
-
+
public static IEnumerable CreateGetTaskRequestInterceptor(Protocol.Models.CloudTask TaskToReturn)
{
return CreateGetRequestInterceptor(TaskToReturn);
diff --git a/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/Application/ApplicationPackagesIntegrationTests.cs b/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/Application/ApplicationPackagesIntegrationTests.cs
index 7ab9f03eeb55..5108940535ca 100644
--- a/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/Application/ApplicationPackagesIntegrationTests.cs
+++ b/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/Application/ApplicationPackagesIntegrationTests.cs
@@ -31,7 +31,7 @@ public ApplicationPackagesIntegrationTests()
[Fact]
[Trait(TestTraits.Duration.TraitName, TestTraits.Duration.Values.MediumDuration)]
- public async Task IfThereAreApplicationsInTheAccount_ThenListApplicationSummariesReturnsThem()
+ public async Task IfThereAreApplicationsInTheAccountThenListApplicationSummariesReturnsThem()
{
Func test = async () =>
{
diff --git a/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/Application/ApplicationPackagesReferencesOnTasksIntegrationTests.cs b/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/Application/ApplicationPackagesReferencesOnTasksIntegrationTests.cs
new file mode 100644
index 000000000000..7e4eee61c8d0
--- /dev/null
+++ b/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/Application/ApplicationPackagesReferencesOnTasksIntegrationTests.cs
@@ -0,0 +1,137 @@
+namespace BatchClientIntegrationTests.Application
+{
+ using System;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Fixtures;
+ using IntegrationTestUtilities;
+ using BatchTestCommon;
+ using Microsoft.Azure.Batch;
+ using Microsoft.Azure.Batch.Common;
+ using Xunit;
+
+ public class ApplicationPackagesReferencesOnTasksIntegrationTests
+ {
+ private static readonly TimeSpan TestTimeout = TimeSpan.FromMinutes(4);
+
+ [Fact]
+ [Trait(TestTraits.Duration.TraitName, TestTraits.Duration.Values.MediumDuration)]
+ public async Task ApplicationPackageReferencesOnCloudTaskAreRoundtripped()
+ {
+ string jobId = Constants.DefaultConveniencePrefix + TestUtilities.GetMyName() + "-APROnCloudTaskAreRoundtripped";
+ string taskId = "task-id";
+
+ const string applicationId = "blender";
+ const string applicationVerson = "beta";
+
+ Func test = async () =>
+ {
+ using (BatchClient client = await TestUtilities.OpenBatchClientFromEnvironmentAsync().ConfigureAwait(false))
+ {
+ var poolInfo = new PoolInformation
+ {
+ AutoPoolSpecification = new AutoPoolSpecification
+ {
+ PoolSpecification = new PoolSpecification
+ {
+ CloudServiceConfiguration = new CloudServiceConfiguration(PoolFixture.OSFamily),
+ VirtualMachineSize = PoolFixture.VMSize,
+ },
+ PoolLifetimeOption = PoolLifetimeOption.Job
+ }
+ };
+
+ try
+ {
+ CloudJob job = client.JobOperations.CreateJob(jobId, poolInfo);
+ await job.CommitAsync().ConfigureAwait(false);
+
+ var boundJob = await client.JobOperations.GetJobAsync(jobId).ConfigureAwait(false);
+
+ CloudTask cloudTask = new CloudTask(taskId, "cmd /c ping 127.0.0.1")
+ {
+ ApplicationPackageReferences = new[]
+ {
+ new ApplicationPackageReference
+ {
+ ApplicationId = applicationId,
+ Version = applicationVerson
+ }
+ }
+ };
+
+ await boundJob.AddTaskAsync(cloudTask).ConfigureAwait(false);
+
+ CloudTask boundCloudTask = await boundJob.GetTaskAsync(taskId).ConfigureAwait(false);
+ Assert.Equal(applicationId, boundCloudTask.ApplicationPackageReferences.Single().ApplicationId);
+ Assert.Equal(applicationVerson, boundCloudTask.ApplicationPackageReferences.Single().Version);
+
+ }
+ finally
+ {
+ TestUtilities.DeleteJobIfExistsAsync(client, jobId).Wait();
+ }
+ }
+ };
+
+ await SynchronizationContextHelper.RunTestAsync(test, TestTimeout);
+ }
+
+ [Fact]
+ [Trait(TestTraits.Duration.TraitName, TestTraits.Duration.Values.MediumDuration)]
+ public async Task ApplicationPackageReferencesOnJobManagerTaskAreRoundtripped()
+ {
+ string jobId = Constants.DefaultConveniencePrefix + TestUtilities.GetMyName() + "-APROnJobManagerTaskAreRoundtripped";
+ const string applicationId = "blender";
+ const string applicationVersion = "beta";
+
+ Func test = async () =>
+ {
+ using (BatchClient client = await TestUtilities.OpenBatchClientFromEnvironmentAsync().ConfigureAwait(false))
+ {
+ var poolInfo = new PoolInformation
+ {
+ AutoPoolSpecification = new AutoPoolSpecification
+ {
+ PoolSpecification = new PoolSpecification
+ {
+ CloudServiceConfiguration = new CloudServiceConfiguration(PoolFixture.OSFamily),
+ VirtualMachineSize = PoolFixture.VMSize,
+ },
+ PoolLifetimeOption = PoolLifetimeOption.Job
+ }
+ };
+
+ try
+ {
+ CloudJob job = client.JobOperations.CreateJob(jobId, poolInfo);
+ job.JobManagerTask = new JobManagerTask
+ {
+ Id = jobId,
+ CommandLine = "cmd /c ping 127.0.0.1",
+ ApplicationPackageReferences = new[]{ new ApplicationPackageReference
+ {
+ ApplicationId = applicationId,
+ Version = applicationVersion
+ }}
+ };
+
+ await job.CommitAsync().ConfigureAwait(false);
+
+ var boundJob = await client.JobOperations.GetJobAsync(jobId).ConfigureAwait(false);
+
+ Assert.Equal(applicationId, boundJob.JobManagerTask.ApplicationPackageReferences.Single().ApplicationId);
+ Assert.Equal(applicationVersion, boundJob.JobManagerTask.ApplicationPackageReferences.Single().Version);
+
+ }
+ finally
+ {
+ TestUtilities.DeleteJobIfExistsAsync(client, jobId).Wait();
+ }
+ }
+ };
+
+ await SynchronizationContextHelper.RunTestAsync(test, TestTimeout);
+ }
+ }
+}
diff --git a/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/BatchClientIntegrationTests.csproj b/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/BatchClientIntegrationTests.csproj
index be5e35a50183..7aa45d1a4f54 100644
--- a/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/BatchClientIntegrationTests.csproj
+++ b/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/BatchClientIntegrationTests.csproj
@@ -137,6 +137,7 @@
+
diff --git a/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/CloudJobIntegrationTests.cs b/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/CloudJobIntegrationTests.cs
index abaf500bc98f..d89b2e7ebf8b 100644
--- a/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/CloudJobIntegrationTests.cs
+++ b/src/Batch/Client/Tests/ObjectModel/BatchClientIntegrationTests/CloudJobIntegrationTests.cs
@@ -470,7 +470,6 @@ public void IfJobSetsOnTaskFailed_JobCompletesWhenAnyTaskFails()
TestUtilities.WaitForJobStateAsync(boundJob, TimeSpan.FromMinutes(2), JobState.Completed).Wait();
Assert.Equal(JobState.Completed, boundJob.State);
-
Assert.Equal("TaskFailed", boundJob.ExecutionInformation.TerminateReason);
}
}
diff --git a/src/Batch/Client/Tools/ObjectModelCodeGeneration/ObjectModelCodeGenerator/BatchProperties.json b/src/Batch/Client/Tools/ObjectModelCodeGeneration/ObjectModelCodeGenerator/BatchProperties.json
index 521b4eb80fbc..5fd6bca85b61 100644
--- a/src/Batch/Client/Tools/ObjectModelCodeGeneration/ObjectModelCodeGenerator/BatchProperties.json
+++ b/src/Batch/Client/Tools/ObjectModelCodeGeneration/ObjectModelCodeGenerator/BatchProperties.json
@@ -100,14 +100,14 @@
{
"Name": "ApplicationPackageReference",
"ProtocolName": "Models.ApplicationPackageReference",
- "Comment": "A reference to an application package to be installed on compute nodes in a pool.",
+ "Comment": "A reference to an application package to be deployed to compute nodes.",
"IsUsedInCollections": true,
"Properties": [
{
"Key": {
"Type": "string",
"Name": "ApplicationId",
- "SummaryComment": "The id of the application to be installed on the compute nodes. ",
+ "SummaryComment": "The id of the application to be deployed on compute nodes.",
"RemarksComment": null,
"BoundAccess": "read",
"UnboundAccess": "read,write"
@@ -118,8 +118,8 @@
"Key": {
"Type": "string",
"Name": "Version",
- "SummaryComment": "The version of the application to be installed on the compute nodes.",
- "RemarksComment": "If not specified, the default version of the application, as defined in the application settings, is installed. If no default version is defined in the application settings, you must specify a version in the .",
+ "SummaryComment": "The version of the application to be deployed on compute nodes.",
+ "RemarksComment": "If not specified, the default version of the application, as defined in the application settings, is deployed. If no default version is defined in the application settings, you must specify a version in the .",
"BoundAccess": "read",
"UnboundAccess": "read,write"
},
@@ -1724,7 +1724,21 @@
"UnboundAccess": "none"
},
"Value": null
- }
+ },
+ {
+ "Key": {
+ "Type": "IList",
+ "Name": "ApplicationPackageReferences",
+ "SummaryComment": "A list of application packages that the Batch service will deploy to the compute node before running the command line.",
+ "RemarksComment": null,
+ "BoundAccess": "read",
+ "UnboundAccess": "read,write"
+ },
+ "Value": {
+ "Type": "IList",
+ "Name": "ApplicationPackageReferences",
+ },
+ },
]
},
{
@@ -2416,6 +2430,165 @@
},
]
},
+ {
+ "Name": "ExitConditions",
+ "ProtocolName": "Models.ExitConditions",
+ "Comment": "How the Batch service should respond when a task completes.",
+ "IsUsedInCollections": true,
+ "Properties": [
+ {
+ "Key": {
+ "Type": "IList",
+ "Name": "ExitCodes",
+ "SummaryComment": "A list of task exit codes and how the Batch service should respond to them.",
+ "BoundAccess": "read",
+ "UnboundAccess": "read,write"
+ },
+ "Value": {
+ "Type": "IList",
+ "Name": "ExitCodes",
+ }
+ },
+ {
+ "Key": {
+ "Type": "IList",
+ "Name": "ExitCodeRanges",
+ "SummaryComment": "A list of task exit code ranges and how the Batch service should respond to them.",
+ "BoundAccess": "read",
+ "UnboundAccess": "read,write"
+ },
+ "Value": {
+ "Type": "IList",
+ "Name": "ExitCodeRanges",
+ }
+ },
+ {
+ "Key": {
+ "Type": "ExitOptions",
+ "Name": "SchedulingError",
+ "SummaryComment": "How the Batch service should respond if the task fails with a scheduling error.",
+ "BoundAccess": "read",
+ "UnboundAccess": "read,write"
+ },
+ "Value": null,
+ },
+ {
+ "Key": {
+ "Type": "ExitOptions",
+ "Name": "Default",
+ "SummaryComment": "How the Batch service should respond if the task fails with an exit condition not covered by any of the other properties.",
+ "RemarksComment": "This value is used if the task exits with any nonzero exit code not listed in the or collection, or with a scheduling error if the property is not present.",
+ "BoundAccess": "read",
+ "UnboundAccess": "read,write"
+ },
+ "Value": {
+ "Type": "Models.ExitOptions",
+ "Name": "DefaultProperty",
+ }
+ },
+ ]
+ },
+ {
+ "Name": "ExitCodeMapping",
+ "ProtocolName": "Models.ExitCodeMapping",
+ "Comment": "A process exit code and how the Batch service should respond if a task exits with that exit code.",
+ "IsUsedInCollections": true,
+ "Properties": [
+ {
+ "Key": {
+ "Type": "int",
+ "Name": "Code",
+ "SummaryComment": "The process exit code.",
+ "BoundAccess": "read",
+ "UnboundAccess": "read,write",
+ "ConstructorArgumentType": "Required",
+ "HideSetter": true
+ },
+ "Value": null,
+ },
+ {
+ "Key": {
+ "Type": "ExitOptions",
+ "Name": "ExitOptions",
+ "SummaryComment": "How the Batch service should respond if the task exits with this exit code.",
+ "BoundAccess": "read",
+ "UnboundAccess": "read,write",
+ "ConstructorArgumentType": "Required",
+ "HideSetter": true
+ },
+ "Value": null,
+ },
+ ]
+ },
+ {
+ "Name": "ExitCodeRangeMapping",
+ "ProtocolName": "Models.ExitCodeRangeMapping",
+ "Comment": "A range of exit codes and how the Batch service should respond if a task exits with an exit code within that range.",
+ "IsUsedInCollections": true,
+ "ForceConstructorOrder": true,
+ "Properties": [
+ {
+ "Key": {
+ "Type": "int",
+ "Name": "Start",
+ "SummaryComment": "The first exit code in the range.",
+ "BoundAccess": "read",
+ "UnboundAccess": "read,write",
+ "ConstructorArgumentType": "Required",
+ "HideSetter": true
+ },
+ "Value": null,
+ },
+ {
+ "Key": {
+ "Type": "int",
+ "Name": "End",
+ "SummaryComment": "The last exit code in the range.",
+ "BoundAccess": "read",
+ "UnboundAccess": "read,write",
+ "ConstructorArgumentType": "Required",
+ "HideSetter": true
+ },
+ "Value": null,
+ },
+ {
+ "Key": {
+ "Type": "ExitOptions",
+ "Name": "ExitOptions",
+ "SummaryComment": "An specifying how the Batch service should respond if the task exits with an exit code in the range to .",
+ "BoundAccess": "read",
+ "UnboundAccess": "read,write",
+ "ConstructorArgumentType": "Required",
+ "HideSetter": true
+ },
+ "Value": {
+ "Type": "Models.ExitOptions",
+ "Name": "ExitOptions",
+ }
+ },
+ ]
+ },
+ {
+ "Name": "ExitOptions",
+ "ProtocolName": "Models.ExitOptions",
+ "Comment": "How the Batch service should respond to a particular exit condition.",
+ "IsUsedInCollections": true,
+ "Properties": [
+ {
+ "Key": {
+ "Type": "Common.JobAction?",
+ "Name": "JobAction",
+ "SummaryComment": "An action to take on the job containing the task, if the task completes with the given exit condition and the job's property is .",
+ "BoundAccess": "read",
+ "UnboundAccess": "read,write",
+ },
+ "Value": {
+ "Type": "Models.JobAction?",
+ "Name": "JobAction",
+ }
+ },
+ ]
+ },
{
"Name": "ErrorMessage",
"ProtocolName": "Models.ErrorMessage",
@@ -2777,7 +2950,21 @@
"UnboundAccess": "read,write"
},
"Value": null
- }
+ },
+ {
+ "Key": {
+ "Type": "IList",
+ "Name": "ApplicationPackageReferences",
+ "SummaryComment": "A list of application packages that the Batch service will deploy to the compute node before running the command line.",
+ "RemarksComment": null,
+ "BoundAccess": "read",
+ "UnboundAccess": "read,write"
+ },
+ "Value": {
+ "Type": "IList",
+ "Name": "ApplicationPackageReferences",
+ },
+ },
]
},
{
diff --git a/src/Batch/Src/Common/Enumerations/JobAction.cs b/src/Batch/Src/Common/Enumerations/JobAction.cs
new file mode 100644
index 000000000000..d113a736b3f3
--- /dev/null
+++ b/src/Batch/Src/Common/Enumerations/JobAction.cs
@@ -0,0 +1,41 @@
+//
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+namespace Microsoft.Azure.Batch.Common
+{
+ ///
+ /// An action to take on the job containing a task, when that task completes.
+ ///
+ public enum JobAction
+ {
+ ///
+ /// Take no action.
+ ///
+ None,
+
+ ///
+ /// Disable the job.
+ ///
+ /// This is equivalent to calling with the option.
+ Disable,
+
+ ///
+ /// Terminate the job.
+ ///
+ /// The termination reason in is set to "TaskFailed".
+ Terminate,
+ }
+}
diff --git a/src/Batch/Src/Common/Enumerations/OnAllTasksComplete.cs b/src/Batch/Src/Common/Enumerations/OnAllTasksComplete.cs
new file mode 100644
index 000000000000..65553861f242
--- /dev/null
+++ b/src/Batch/Src/Common/Enumerations/OnAllTasksComplete.cs
@@ -0,0 +1,34 @@
+//
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+namespace Microsoft.Azure.Batch.Common
+{
+ ///
+ /// Specifies an action the Batch service should take when all tasks in the job are in the completed state.
+ ///
+ public enum OnAllTasksComplete
+ {
+ ///
+ /// Do nothing. The job remains active unless terminated or disabled by some other means.
+ ///
+ NoAction,
+
+ ///
+ /// Terminate the job. The job's is set to "AllTasksComplete".
+ ///
+ TerminateJob,
+ }
+}
diff --git a/src/Batch/Src/Common/Enumerations/OnTaskFailure.cs b/src/Batch/Src/Common/Enumerations/OnTaskFailure.cs
new file mode 100644
index 000000000000..f108aa60cbc1
--- /dev/null
+++ b/src/Batch/Src/Common/Enumerations/OnTaskFailure.cs
@@ -0,0 +1,34 @@
+//
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+namespace Microsoft.Azure.Batch.Common
+{
+ ///
+ /// Specifies an action the Batch service should take when any task in the job fails.
+ ///
+ public enum OnTaskFailure
+ {
+ ///
+ /// Do nothing.
+ ///
+ NoAction,
+
+ ///
+ /// Take the action associated with the task exit condition in the task's collection. (This may still result in no action being taken, if that is what the task specifies.)
+ ///
+ PerformExitOptionsJobAction,
+ }
+}
diff --git a/src/Batch/Src/Generated/ExitCodeMapping.cs b/src/Batch/Src/Generated/ExitCodeMapping.cs
new file mode 100644
index 000000000000..5523794d5cbe
--- /dev/null
+++ b/src/Batch/Src/Generated/ExitCodeMapping.cs
@@ -0,0 +1,141 @@
+//****************************************
+// This file was autogenerated by a tool.
+// Do not modify it.
+//****************************************
+namespace Microsoft.Azure.Batch
+{
+ using Models = Microsoft.Azure.Batch.Protocol.Models;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// A process exit code and how the Batch service should respond if a task exits with that exit code.
+ ///
+ public partial class ExitCodeMapping : ITransportObjectProvider, IPropertyMetadata
+ {
+ private readonly int code;
+ private readonly ExitOptions exitOptions;
+
+ #region Constructors
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The process exit code.
+ /// How the Batch service should respond if the task exits with this exit code.
+ public ExitCodeMapping(
+ int code,
+ ExitOptions exitOptions)
+ {
+ this.code = code;
+ this.exitOptions = exitOptions;
+ }
+
+ internal ExitCodeMapping(Models.ExitCodeMapping protocolObject)
+ {
+ this.code = protocolObject.Code;
+ this.exitOptions = UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.ExitOptions, o => new ExitOptions(o).Freeze());
+ }
+
+ #endregion Constructors
+
+ #region ExitCodeMapping
+
+ ///
+ /// Gets the process exit code.
+ ///
+ public int Code
+ {
+ get { return this.code; }
+ }
+
+ ///
+ /// Gets how the Batch service should respond if the task exits with this exit code.
+ ///
+ public ExitOptions ExitOptions
+ {
+ get { return this.exitOptions; }
+ }
+
+ #endregion // ExitCodeMapping
+
+ #region IPropertyMetadata
+
+ bool IModifiable.HasBeenModified
+ {
+ //This class is compile time readonly so it cannot have been modified
+ get { return false; }
+ }
+
+ bool IReadOnly.IsReadOnly
+ {
+ get { return true; }
+ set
+ {
+ // This class is compile time readonly already
+ }
+ }
+
+ #endregion // IPropertyMetadata
+
+ #region Internal/private methods
+
+ ///
+ /// Return a protocol object of the requested type.
+ ///
+ /// The protocol object of the requested type.
+ Models.ExitCodeMapping ITransportObjectProvider.GetTransportObject()
+ {
+ Models.ExitCodeMapping result = new Models.ExitCodeMapping()
+ {
+ Code = this.Code,
+ ExitOptions = UtilitiesInternal.CreateObjectWithNullCheck(this.ExitOptions, (o) => o.GetTransportObject()),
+ };
+
+ return result;
+ }
+
+ ///
+ /// Converts a collection of protocol layer objects to object layer collection objects.
+ ///
+ internal static IList ConvertFromProtocolCollection(IEnumerable protoCollection)
+ {
+ ConcurrentChangeTrackedModifiableList converted = UtilitiesInternal.CollectionToThreadSafeCollectionIModifiable(
+ items: protoCollection,
+ objectCreationFunc: o => new ExitCodeMapping(o));
+
+ return converted;
+ }
+
+ ///
+ /// Converts a collection of protocol layer objects to object layer collection objects, in a frozen state.
+ ///
+ internal static IList ConvertFromProtocolCollectionAndFreeze(IEnumerable protoCollection)
+ {
+ ConcurrentChangeTrackedModifiableList converted = UtilitiesInternal.CollectionToThreadSafeCollectionIModifiable(
+ items: protoCollection,
+ objectCreationFunc: o => new ExitCodeMapping(o).Freeze());
+
+ converted = UtilitiesInternal.CreateObjectWithNullCheck(converted, o => o.Freeze());
+
+ return converted;
+ }
+
+ ///
+ /// Converts a collection of protocol layer objects to object layer collection objects, with each object marked readonly
+ /// and returned as a readonly collection.
+ ///
+ internal static IReadOnlyList ConvertFromProtocolCollectionReadOnly(IEnumerable protoCollection)
+ {
+ IReadOnlyList converted =
+ UtilitiesInternal.CreateObjectWithNullCheck(
+ UtilitiesInternal.CollectionToNonThreadSafeCollection(
+ items: protoCollection,
+ objectCreationFunc: o => new ExitCodeMapping(o).Freeze()), o => o.AsReadOnly());
+
+ return converted;
+ }
+
+ #endregion // Internal/private methods
+ }
+}
\ No newline at end of file
diff --git a/src/Batch/Src/Generated/ExitCodeRangeMapping.cs b/src/Batch/Src/Generated/ExitCodeRangeMapping.cs
new file mode 100644
index 000000000000..07c78ce3e952
--- /dev/null
+++ b/src/Batch/Src/Generated/ExitCodeRangeMapping.cs
@@ -0,0 +1,157 @@
+//****************************************
+// This file was autogenerated by a tool.
+// Do not modify it.
+//****************************************
+namespace Microsoft.Azure.Batch
+{
+ using Models = Microsoft.Azure.Batch.Protocol.Models;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// A range of exit codes and how the Batch service should respond if a task exits with an exit code within that range.
+ ///
+ public partial class ExitCodeRangeMapping : ITransportObjectProvider, IPropertyMetadata
+ {
+ private readonly int end;
+ private readonly ExitOptions exitOptions;
+ private readonly int start;
+
+ #region Constructors
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The first exit code in the range.
+ /// The last exit code in the range.
+ /// An specifying how the Batch service should respond if the task exits with an exit
+ /// code in the range to .
+ public ExitCodeRangeMapping(
+ int start,
+ int end,
+ ExitOptions exitOptions)
+ {
+ this.start = start;
+ this.end = end;
+ this.exitOptions = exitOptions;
+ }
+
+ internal ExitCodeRangeMapping(Models.ExitCodeRangeMapping protocolObject)
+ {
+ this.end = protocolObject.End;
+ this.exitOptions = UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.ExitOptions, o => new ExitOptions(o).Freeze());
+ this.start = protocolObject.Start;
+ }
+
+ #endregion Constructors
+
+ #region ExitCodeRangeMapping
+
+ ///
+ /// Gets the last exit code in the range.
+ ///
+ public int End
+ {
+ get { return this.end; }
+ }
+
+ ///
+ /// Gets an specifying how the Batch service should respond if the task exits with an
+ /// exit code in the range to .
+ ///
+ public ExitOptions ExitOptions
+ {
+ get { return this.exitOptions; }
+ }
+
+ ///
+ /// Gets the first exit code in the range.
+ ///
+ public int Start
+ {
+ get { return this.start; }
+ }
+
+ #endregion // ExitCodeRangeMapping
+
+ #region IPropertyMetadata
+
+ bool IModifiable.HasBeenModified
+ {
+ //This class is compile time readonly so it cannot have been modified
+ get { return false; }
+ }
+
+ bool IReadOnly.IsReadOnly
+ {
+ get { return true; }
+ set
+ {
+ // This class is compile time readonly already
+ }
+ }
+
+ #endregion // IPropertyMetadata
+
+ #region Internal/private methods
+
+ ///
+ /// Return a protocol object of the requested type.
+ ///
+ /// The protocol object of the requested type.
+ Models.ExitCodeRangeMapping ITransportObjectProvider.GetTransportObject()
+ {
+ Models.ExitCodeRangeMapping result = new Models.ExitCodeRangeMapping()
+ {
+ End = this.End,
+ ExitOptions = UtilitiesInternal.CreateObjectWithNullCheck(this.ExitOptions, (o) => o.GetTransportObject()),
+ Start = this.Start,
+ };
+
+ return result;
+ }
+
+ ///
+ /// Converts a collection of protocol layer objects to object layer collection objects.
+ ///
+ internal static IList ConvertFromProtocolCollection(IEnumerable protoCollection)
+ {
+ ConcurrentChangeTrackedModifiableList converted = UtilitiesInternal.CollectionToThreadSafeCollectionIModifiable(
+ items: protoCollection,
+ objectCreationFunc: o => new ExitCodeRangeMapping(o));
+
+ return converted;
+ }
+
+ ///
+ /// Converts a collection of protocol layer objects to object layer collection objects, in a frozen state.
+ ///
+ internal static IList ConvertFromProtocolCollectionAndFreeze(IEnumerable protoCollection)
+ {
+ ConcurrentChangeTrackedModifiableList converted = UtilitiesInternal.CollectionToThreadSafeCollectionIModifiable(
+ items: protoCollection,
+ objectCreationFunc: o => new ExitCodeRangeMapping(o).Freeze());
+
+ converted = UtilitiesInternal.CreateObjectWithNullCheck(converted, o => o.Freeze());
+
+ return converted;
+ }
+
+ ///
+ /// Converts a collection of protocol layer objects to object layer collection objects, with each object marked readonly
+ /// and returned as a readonly collection.
+ ///
+ internal static IReadOnlyList ConvertFromProtocolCollectionReadOnly(IEnumerable protoCollection)
+ {
+ IReadOnlyList converted =
+ UtilitiesInternal.CreateObjectWithNullCheck(
+ UtilitiesInternal.CollectionToNonThreadSafeCollection(
+ items: protoCollection,
+ objectCreationFunc: o => new ExitCodeRangeMapping(o).Freeze()), o => o.AsReadOnly());
+
+ return converted;
+ }
+
+ #endregion // Internal/private methods
+ }
+}
\ No newline at end of file
diff --git a/src/Batch/Src/Generated/ExitConditions.cs b/src/Batch/Src/Generated/ExitConditions.cs
new file mode 100644
index 000000000000..1d18c790c6e6
--- /dev/null
+++ b/src/Batch/Src/Generated/ExitConditions.cs
@@ -0,0 +1,200 @@
+//****************************************
+// This file was autogenerated by a tool.
+// Do not modify it.
+//****************************************
+namespace Microsoft.Azure.Batch
+{
+ using Models = Microsoft.Azure.Batch.Protocol.Models;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// How the Batch service should respond when a task completes.
+ ///
+ public partial class ExitConditions : ITransportObjectProvider, IPropertyMetadata
+ {
+ private class PropertyContainer : PropertyCollection
+ {
+ public readonly PropertyAccessor DefaultProperty;
+ public readonly PropertyAccessor> ExitCodeRangesProperty;
+ public readonly PropertyAccessor> ExitCodesProperty;
+ public readonly PropertyAccessor SchedulingErrorProperty;
+
+ public PropertyContainer() : base(BindingState.Unbound)
+ {
+ this.DefaultProperty = this.CreatePropertyAccessor("Default", BindingAccess.Read | BindingAccess.Write);
+ this.ExitCodeRangesProperty = this.CreatePropertyAccessor>("ExitCodeRanges", BindingAccess.Read | BindingAccess.Write);
+ this.ExitCodesProperty = this.CreatePropertyAccessor>("ExitCodes", BindingAccess.Read | BindingAccess.Write);
+ this.SchedulingErrorProperty = this.CreatePropertyAccessor("SchedulingError", BindingAccess.Read | BindingAccess.Write);
+ }
+
+ public PropertyContainer(Models.ExitConditions protocolObject) : base(BindingState.Bound)
+ {
+ this.DefaultProperty = this.CreatePropertyAccessor(
+ UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.DefaultProperty, o => new ExitOptions(o).Freeze()),
+ "Default",
+ BindingAccess.Read);
+ this.ExitCodeRangesProperty = this.CreatePropertyAccessor(
+ ExitCodeRangeMapping.ConvertFromProtocolCollectionAndFreeze(protocolObject.ExitCodeRanges),
+ "ExitCodeRanges",
+ BindingAccess.Read);
+ this.ExitCodesProperty = this.CreatePropertyAccessor(
+ ExitCodeMapping.ConvertFromProtocolCollectionAndFreeze(protocolObject.ExitCodes),
+ "ExitCodes",
+ BindingAccess.Read);
+ this.SchedulingErrorProperty = this.CreatePropertyAccessor(
+ UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.SchedulingError, o => new ExitOptions(o).Freeze()),
+ "SchedulingError",
+ BindingAccess.Read);
+ }
+ }
+
+ private readonly PropertyContainer propertyContainer;
+
+ #region Constructors
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ExitConditions()
+ {
+ this.propertyContainer = new PropertyContainer();
+ }
+
+ internal ExitConditions(Models.ExitConditions protocolObject)
+ {
+ this.propertyContainer = new PropertyContainer(protocolObject);
+ }
+
+ #endregion Constructors
+
+ #region ExitConditions
+
+ ///
+ /// Gets or sets how the Batch service should respond if the task fails with an exit condition not covered by any
+ /// of the other properties.
+ ///
+ ///
+ /// This value is used if the task exits with any nonzero exit code not listed in the or
+ /// collection, or with a scheduling error if the property
+ /// is not present.
+ ///
+ public ExitOptions Default
+ {
+ get { return this.propertyContainer.DefaultProperty.Value; }
+ set { this.propertyContainer.DefaultProperty.Value = value; }
+ }
+
+ ///
+ /// Gets or sets a list of task exit code ranges and how the Batch service should respond to them.
+ ///
+ public IList ExitCodeRanges
+ {
+ get { return this.propertyContainer.ExitCodeRangesProperty.Value; }
+ set
+ {
+ this.propertyContainer.ExitCodeRangesProperty.Value = ConcurrentChangeTrackedModifiableList.TransformEnumerableToConcurrentModifiableList(value);
+ }
+ }
+
+ ///
+ /// Gets or sets a list of task exit codes and how the Batch service should respond to them.
+ ///
+ public IList ExitCodes
+ {
+ get { return this.propertyContainer.ExitCodesProperty.Value; }
+ set
+ {
+ this.propertyContainer.ExitCodesProperty.Value = ConcurrentChangeTrackedModifiableList.TransformEnumerableToConcurrentModifiableList(value);
+ }
+ }
+
+ ///
+ /// Gets or sets how the Batch service should respond if the task fails with a scheduling error.
+ ///
+ public ExitOptions SchedulingError
+ {
+ get { return this.propertyContainer.SchedulingErrorProperty.Value; }
+ set { this.propertyContainer.SchedulingErrorProperty.Value = value; }
+ }
+
+ #endregion // ExitConditions
+
+ #region IPropertyMetadata
+
+ bool IModifiable.HasBeenModified
+ {
+ get { return this.propertyContainer.HasBeenModified; }
+ }
+
+ bool IReadOnly.IsReadOnly
+ {
+ get { return this.propertyContainer.IsReadOnly; }
+ set { this.propertyContainer.IsReadOnly = value; }
+ }
+
+ #endregion //IPropertyMetadata
+
+ #region Internal/private methods
+ ///
+ /// Return a protocol object of the requested type.
+ ///
+ /// The protocol object of the requested type.
+ Models.ExitConditions ITransportObjectProvider.GetTransportObject()
+ {
+ Models.ExitConditions result = new Models.ExitConditions()
+ {
+ DefaultProperty = UtilitiesInternal.CreateObjectWithNullCheck(this.Default, (o) => o.GetTransportObject()),
+ ExitCodeRanges = UtilitiesInternal.ConvertToProtocolCollection(this.ExitCodeRanges),
+ ExitCodes = UtilitiesInternal.ConvertToProtocolCollection(this.ExitCodes),
+ SchedulingError = UtilitiesInternal.CreateObjectWithNullCheck(this.SchedulingError, (o) => o.GetTransportObject()),
+ };
+
+ return result;
+ }
+
+ ///
+ /// Converts a collection of protocol layer objects to object layer collection objects.
+ ///
+ internal static IList ConvertFromProtocolCollection(IEnumerable protoCollection)
+ {
+ ConcurrentChangeTrackedModifiableList converted = UtilitiesInternal.CollectionToThreadSafeCollectionIModifiable(
+ items: protoCollection,
+ objectCreationFunc: o => new ExitConditions(o));
+
+ return converted;
+ }
+
+ ///
+ /// Converts a collection of protocol layer objects to object layer collection objects, in a frozen state.
+ ///
+ internal static IList ConvertFromProtocolCollectionAndFreeze(IEnumerable protoCollection)
+ {
+ ConcurrentChangeTrackedModifiableList converted = UtilitiesInternal.CollectionToThreadSafeCollectionIModifiable(
+ items: protoCollection,
+ objectCreationFunc: o => new ExitConditions(o).Freeze());
+
+ converted = UtilitiesInternal.CreateObjectWithNullCheck(converted, o => o.Freeze());
+
+ return converted;
+ }
+
+ ///
+ /// Converts a collection of protocol layer objects to object layer collection objects, with each object marked readonly
+ /// and returned as a readonly collection.
+ ///
+ internal static IReadOnlyList ConvertFromProtocolCollectionReadOnly(IEnumerable protoCollection)
+ {
+ IReadOnlyList converted =
+ UtilitiesInternal.CreateObjectWithNullCheck(
+ UtilitiesInternal.CollectionToNonThreadSafeCollection(
+ items: protoCollection,
+ objectCreationFunc: o => new ExitConditions(o).Freeze()), o => o.AsReadOnly());
+
+ return converted;
+ }
+
+ #endregion // Internal/private methods
+ }
+}
\ No newline at end of file
diff --git a/src/Batch/Src/Generated/ExitOptions.cs b/src/Batch/Src/Generated/ExitOptions.cs
new file mode 100644
index 000000000000..d7a197b90d1d
--- /dev/null
+++ b/src/Batch/Src/Generated/ExitOptions.cs
@@ -0,0 +1,141 @@
+//****************************************
+// This file was autogenerated by a tool.
+// Do not modify it.
+//****************************************
+namespace Microsoft.Azure.Batch
+{
+ using Models = Microsoft.Azure.Batch.Protocol.Models;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// How the Batch service should respond to a particular exit condition.
+ ///
+ public partial class ExitOptions : ITransportObjectProvider, IPropertyMetadata
+ {
+ private class PropertyContainer : PropertyCollection
+ {
+ public readonly PropertyAccessor JobActionProperty;
+
+ public PropertyContainer() : base(BindingState.Unbound)
+ {
+ this.JobActionProperty = this.CreatePropertyAccessor("JobAction", BindingAccess.Read | BindingAccess.Write);
+ }
+
+ public PropertyContainer(Models.ExitOptions protocolObject) : base(BindingState.Bound)
+ {
+ this.JobActionProperty = this.CreatePropertyAccessor(
+ UtilitiesInternal.MapNullableEnum(protocolObject.JobAction),
+ "JobAction",
+ BindingAccess.Read);
+ }
+ }
+
+ private readonly PropertyContainer propertyContainer;
+
+ #region Constructors
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ExitOptions()
+ {
+ this.propertyContainer = new PropertyContainer();
+ }
+
+ internal ExitOptions(Models.ExitOptions protocolObject)
+ {
+ this.propertyContainer = new PropertyContainer(protocolObject);
+ }
+
+ #endregion Constructors
+
+ #region ExitOptions
+
+ ///
+ /// Gets or sets an action to take on the job containing the task, if the task completes with the given exit condition
+ /// and the job's property is .
+ ///
+ public Common.JobAction? JobAction
+ {
+ get { return this.propertyContainer.JobActionProperty.Value; }
+ set { this.propertyContainer.JobActionProperty.Value = value; }
+ }
+
+ #endregion // ExitOptions
+
+ #region IPropertyMetadata
+
+ bool IModifiable.HasBeenModified
+ {
+ get { return this.propertyContainer.HasBeenModified; }
+ }
+
+ bool IReadOnly.IsReadOnly
+ {
+ get { return this.propertyContainer.IsReadOnly; }
+ set { this.propertyContainer.IsReadOnly = value; }
+ }
+
+ #endregion //IPropertyMetadata
+
+ #region Internal/private methods
+ ///
+ /// Return a protocol object of the requested type.
+ ///
+ /// The protocol object of the requested type.
+ Models.ExitOptions ITransportObjectProvider.GetTransportObject()
+ {
+ Models.ExitOptions result = new Models.ExitOptions()
+ {
+ JobAction = UtilitiesInternal.MapNullableEnum(this.JobAction),
+ };
+
+ return result;
+ }
+
+ ///
+ /// Converts a collection of protocol layer objects to object layer collection objects.
+ ///
+ internal static IList ConvertFromProtocolCollection(IEnumerable protoCollection)
+ {
+ ConcurrentChangeTrackedModifiableList converted = UtilitiesInternal.CollectionToThreadSafeCollectionIModifiable(
+ items: protoCollection,
+ objectCreationFunc: o => new ExitOptions(o));
+
+ return converted;
+ }
+
+ ///
+ /// Converts a collection of protocol layer objects to object layer collection objects, in a frozen state.
+ ///
+ internal static IList ConvertFromProtocolCollectionAndFreeze(IEnumerable protoCollection)
+ {
+ ConcurrentChangeTrackedModifiableList converted = UtilitiesInternal.CollectionToThreadSafeCollectionIModifiable(
+ items: protoCollection,
+ objectCreationFunc: o => new ExitOptions(o).Freeze());
+
+ converted = UtilitiesInternal.CreateObjectWithNullCheck(converted, o => o.Freeze());
+
+ return converted;
+ }
+
+ ///
+ /// Converts a collection of protocol layer objects to object layer collection objects, with each object marked readonly
+ /// and returned as a readonly collection.
+ ///
+ internal static IReadOnlyList ConvertFromProtocolCollectionReadOnly(IEnumerable protoCollection)
+ {
+ IReadOnlyList converted =
+ UtilitiesInternal.CreateObjectWithNullCheck(
+ UtilitiesInternal.CollectionToNonThreadSafeCollection(
+ items: protoCollection,
+ objectCreationFunc: o => new ExitOptions(o).Freeze()), o => o.AsReadOnly());
+
+ return converted;
+ }
+
+ #endregion // Internal/private methods
+ }
+}
\ No newline at end of file
diff --git a/src/Batch/Src/GeneratedProtocol/Models/ExitCodeMapping.cs b/src/Batch/Src/GeneratedProtocol/Models/ExitCodeMapping.cs
new file mode 100644
index 000000000000..7d07abfd5083
--- /dev/null
+++ b/src/Batch/Src/GeneratedProtocol/Models/ExitCodeMapping.cs
@@ -0,0 +1,76 @@
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Batch.Protocol.Models
+{
+ using System;
+ using System.Linq;
+ using System.Collections.Generic;
+ using Newtonsoft.Json;
+ using Microsoft.Rest;
+ using Microsoft.Rest.Serialization;
+ using Microsoft.Rest.Azure;
+
+ ///
+ /// A process exit code and how the Batch service should respond if a task
+ /// exits with that exit code.
+ ///
+ public partial class ExitCodeMapping
+ {
+ ///
+ /// Initializes a new instance of the ExitCodeMapping class.
+ ///
+ public ExitCodeMapping() { }
+
+ ///
+ /// Initializes a new instance of the ExitCodeMapping class.
+ ///
+ public ExitCodeMapping(int code, ExitOptions exitOptions)
+ {
+ Code = code;
+ ExitOptions = exitOptions;
+ }
+
+ ///
+ /// Gets or sets the process exit code.
+ ///
+ [JsonProperty(PropertyName = "code")]
+ public int Code { get; set; }
+
+ ///
+ /// Gets or sets how the Batch service should respond if the task
+ /// exits with this exit code.
+ ///
+ [JsonProperty(PropertyName = "exitOptions")]
+ public ExitOptions ExitOptions { get; set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (ExitOptions == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "ExitOptions");
+ }
+ }
+ }
+}
diff --git a/src/Batch/Src/GeneratedProtocol/Models/ExitCodeRangeMapping.cs b/src/Batch/Src/GeneratedProtocol/Models/ExitCodeRangeMapping.cs
new file mode 100644
index 000000000000..5b4bf099bb2e
--- /dev/null
+++ b/src/Batch/Src/GeneratedProtocol/Models/ExitCodeRangeMapping.cs
@@ -0,0 +1,83 @@
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Batch.Protocol.Models
+{
+ using System;
+ using System.Linq;
+ using System.Collections.Generic;
+ using Newtonsoft.Json;
+ using Microsoft.Rest;
+ using Microsoft.Rest.Serialization;
+ using Microsoft.Rest.Azure;
+
+ ///
+ /// A range of exit codes and how the Batch service should respond to the
+ /// exit codes within that range.
+ ///
+ public partial class ExitCodeRangeMapping
+ {
+ ///
+ /// Initializes a new instance of the ExitCodeRangeMapping class.
+ ///
+ public ExitCodeRangeMapping() { }
+
+ ///
+ /// Initializes a new instance of the ExitCodeRangeMapping class.
+ ///
+ public ExitCodeRangeMapping(int start, int end, ExitOptions exitOptions)
+ {
+ Start = start;
+ End = end;
+ ExitOptions = exitOptions;
+ }
+
+ ///
+ /// Gets or sets the first exit code in the range.
+ ///
+ [JsonProperty(PropertyName = "start")]
+ public int Start { get; set; }
+
+ ///
+ /// Gets or sets the last exit code in the range.
+ ///
+ [JsonProperty(PropertyName = "end")]
+ public int End { get; set; }
+
+ ///
+ /// Gets or sets how the Batch service should respond if the task
+ /// exits with an exit code within the range.
+ ///
+ [JsonProperty(PropertyName = "exitOptions")]
+ public ExitOptions ExitOptions { get; set; }
+
+ ///
+ /// Validate the object.
+ ///
+ ///
+ /// Thrown if validation fails
+ ///
+ public virtual void Validate()
+ {
+ if (ExitOptions == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "ExitOptions");
+ }
+ }
+ }
+}
diff --git a/src/Batch/Src/GeneratedProtocol/Models/ExitConditions.cs b/src/Batch/Src/GeneratedProtocol/Models/ExitConditions.cs
new file mode 100644
index 000000000000..6e73ccec5356
--- /dev/null
+++ b/src/Batch/Src/GeneratedProtocol/Models/ExitConditions.cs
@@ -0,0 +1,82 @@
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Batch.Protocol.Models
+{
+ using System;
+ using System.Linq;
+ using System.Collections.Generic;
+ using Newtonsoft.Json;
+ using Microsoft.Rest;
+ using Microsoft.Rest.Serialization;
+ using Microsoft.Rest.Azure;
+
+ ///
+ /// Specifies how the Batch service should respond when the task completes.
+ ///
+ public partial class ExitConditions
+ {
+ ///
+ /// Initializes a new instance of the ExitConditions class.
+ ///
+ public ExitConditions() { }
+
+ ///
+ /// Initializes a new instance of the ExitConditions class.
+ ///
+ public ExitConditions(IList exitCodes = default(IList), IList exitCodeRanges = default(IList), ExitOptions schedulingError = default(ExitOptions), ExitOptions defaultProperty = default(ExitOptions))
+ {
+ ExitCodes = exitCodes;
+ ExitCodeRanges = exitCodeRanges;
+ SchedulingError = schedulingError;
+ DefaultProperty = defaultProperty;
+ }
+
+ ///
+ /// Gets or sets a list of individual task exit codes and how the
+ /// Batch service should respond to them.
+ ///
+ [JsonProperty(PropertyName = "exitCodes")]
+ public IList ExitCodes { get; set; }
+
+ ///
+ /// Gets or sets a list of task exit code ranges and how the Batch
+ /// service should respond to them.
+ ///
+ [JsonProperty(PropertyName = "exitCodeRanges")]
+ public IList ExitCodeRanges { get; set; }
+
+ ///
+ /// Gets or sets how the Batch service should respond if the task
+ /// fails with a scheduling error.
+ ///
+ [JsonProperty(PropertyName = "schedulingError")]
+ public ExitOptions SchedulingError { get; set; }
+
+ ///
+ /// Gets or sets how the Batch service should respond if the task
+ /// fails with an exit condition not covered by any of the other
+ /// properties - that is, any nonzero exit code not listed in the
+ /// exitCodes or exitCodeRanges collection, or a scheduling error if
+ /// the schedulingError property is not present.
+ ///
+ [JsonProperty(PropertyName = "default")]
+ public ExitOptions DefaultProperty { get; set; }
+
+ }
+}
diff --git a/src/Batch/Src/GeneratedProtocol/Models/ExitOptions.cs b/src/Batch/Src/GeneratedProtocol/Models/ExitOptions.cs
new file mode 100644
index 000000000000..247f88364f02
--- /dev/null
+++ b/src/Batch/Src/GeneratedProtocol/Models/ExitOptions.cs
@@ -0,0 +1,57 @@
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Batch.Protocol.Models
+{
+ using System;
+ using System.Linq;
+ using System.Collections.Generic;
+ using Newtonsoft.Json;
+ using Microsoft.Rest;
+ using Microsoft.Rest.Serialization;
+ using Microsoft.Rest.Azure;
+
+ ///
+ /// How the Batch service should respond to a particular exit condition.
+ ///
+ public partial class ExitOptions
+ {
+ ///
+ /// Initializes a new instance of the ExitOptions class.
+ ///
+ public ExitOptions() { }
+
+ ///
+ /// Initializes a new instance of the ExitOptions class.
+ ///
+ public ExitOptions(JobAction? jobAction = default(JobAction?))
+ {
+ JobAction = jobAction;
+ }
+
+ ///
+ /// Gets or sets an action to take on the job containing the task, if
+ /// the task completes with the given exit condition and the job's
+ /// onTaskFailed property is 'performexitoptionsjobaction'. Possible
+ /// values include: 'none', 'disable', 'terminate'
+ ///
+ [JsonProperty(PropertyName = "jobAction")]
+ public JobAction? JobAction { get; set; }
+
+ }
+}
diff --git a/src/Batch/Src/GeneratedProtocol/Models/JobAction.cs b/src/Batch/Src/GeneratedProtocol/Models/JobAction.cs
new file mode 100644
index 000000000000..3fb7aa5a4366
--- /dev/null
+++ b/src/Batch/Src/GeneratedProtocol/Models/JobAction.cs
@@ -0,0 +1,38 @@
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Batch.Protocol.Models
+{
+ using Newtonsoft.Json;
+ using Newtonsoft.Json.Converters;
+ using System.Runtime.Serialization;
+
+ ///
+ /// Defines values for JobAction.
+ ///
+ [JsonConverter(typeof(StringEnumConverter))]
+ public enum JobAction
+ {
+ [EnumMember(Value = "none")]
+ None,
+ [EnumMember(Value = "disable")]
+ Disable,
+ [EnumMember(Value = "terminate")]
+ Terminate
+ }
+}
diff --git a/src/Batch/Src/GeneratedProtocol/Models/OnAllTasksComplete.cs b/src/Batch/Src/GeneratedProtocol/Models/OnAllTasksComplete.cs
new file mode 100644
index 000000000000..ffdea80dc7e4
--- /dev/null
+++ b/src/Batch/Src/GeneratedProtocol/Models/OnAllTasksComplete.cs
@@ -0,0 +1,36 @@
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Batch.Protocol.Models
+{
+ using Newtonsoft.Json;
+ using Newtonsoft.Json.Converters;
+ using System.Runtime.Serialization;
+
+ ///
+ /// Defines values for OnAllTasksComplete.
+ ///
+ [JsonConverter(typeof(StringEnumConverter))]
+ public enum OnAllTasksComplete
+ {
+ [EnumMember(Value = "noAction")]
+ NoAction,
+ [EnumMember(Value = "terminateJob")]
+ TerminateJob
+ }
+}
diff --git a/src/Batch/Src/GeneratedProtocol/Models/OnTaskFailure.cs b/src/Batch/Src/GeneratedProtocol/Models/OnTaskFailure.cs
new file mode 100644
index 000000000000..242b4f6653ba
--- /dev/null
+++ b/src/Batch/Src/GeneratedProtocol/Models/OnTaskFailure.cs
@@ -0,0 +1,36 @@
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Batch.Protocol.Models
+{
+ using Newtonsoft.Json;
+ using Newtonsoft.Json.Converters;
+ using System.Runtime.Serialization;
+
+ ///
+ /// Defines values for OnTaskFailure.
+ ///
+ [JsonConverter(typeof(StringEnumConverter))]
+ public enum OnTaskFailure
+ {
+ [EnumMember(Value = "noAction")]
+ NoAction,
+ [EnumMember(Value = "performExitOptionsJobAction")]
+ PerformExitOptionsJobAction
+ }
+}
diff --git a/src/Batch/Tests/ObjectModel/BatchClientIntegrationTests/Application/ApplicationPackagesReferencesOnTasksIntegrationTests.cs b/src/Batch/Tests/ObjectModel/BatchClientIntegrationTests/Application/ApplicationPackagesReferencesOnTasksIntegrationTests.cs
new file mode 100644
index 000000000000..1e9bc5fb837d
--- /dev/null
+++ b/src/Batch/Tests/ObjectModel/BatchClientIntegrationTests/Application/ApplicationPackagesReferencesOnTasksIntegrationTests.cs
@@ -0,0 +1,162 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+using BatchClientIntegrationTests.Fixtures;
+using BatchClientIntegrationTests.IntegrationTestUtilities;
+
+using BatchTestCommon;
+
+using Microsoft.Azure.Batch;
+using Microsoft.Azure.Batch.Common;
+using Microsoft.Azure.Batch.Protocol;
+
+using Xunit;
+
+namespace BatchClientIntegrationTests.Application
+{
+ public class ApplicationPackagesReferencesOnTasksIntegrationTests
+ {
+ private static readonly TimeSpan TestTimeout = TimeSpan.FromMinutes(4);
+
+ [Fact]
+ [Trait(TestTraits.Duration.TraitName, TestTraits.Duration.Values.MediumDuration)]
+ public async Task CanCreateCloudTasksWithAppPackageReferences()
+ {
+ var jobId = TestUtilities.GetMyName()+ "-"+ Guid.NewGuid();
+ var taskId = "task-id";
+
+ const string applicationId = "blender";
+
+ Func test = async () =>
+ {
+ using (BatchClient client = await TestUtilities.OpenBatchClientFromEnvironmentAsync().ConfigureAwait(false))
+ {
+ var poolInfo = new PoolInformation
+ {
+ AutoPoolSpecification = new AutoPoolSpecification
+ {
+ PoolSpecification = new PoolSpecification
+ {
+ CloudServiceConfiguration = new CloudServiceConfiguration(PoolFixture.OSFamily),
+ VirtualMachineSize = PoolFixture.VMSize,
+ },
+ PoolLifetimeOption = PoolLifetimeOption.Job
+ }
+ };
+
+ CloudJob response = null;
+ try
+ {
+ CloudJob job = client.JobOperations.CreateJob(jobId, poolInfo);
+ await job.CommitAsync().ConfigureAwait(false);
+
+ response = await client.JobOperations.GetJobAsync(jobId).ConfigureAwait(false);
+
+ CloudTask cloudTask = new CloudTask(taskId, "cmd /c ping 127.0.0.1")
+ {
+ ApplicationPackageReferences =
+ new[]
+ {
+ new ApplicationPackageReference
+ {
+ ApplicationId = applicationId,
+ Version = PoolFixture.VMSize
+ }
+ }
+ };
+
+ await response.AddTaskAsync(cloudTask);
+
+ CloudTask cloudTaskResponse = await response.GetTaskAsync(taskId);
+
+ }
+ finally
+ {
+ if (response != null)
+ {
+ TestUtilities.DeleteJobIfExistsAsync(client, jobId).Wait();
+ }
+ }
+ }
+ };
+
+ await SynchronizationContextHelper.RunTestAsync(test, TestTimeout);
+ }
+
+ [Fact]
+ [Trait(TestTraits.Duration.TraitName, TestTraits.Duration.Values.MediumDuration)]
+ public async Task CanCreateJobManagerTaskWithAppPackageReferences()
+ {
+ var jobId = TestUtilities.GetMyName() + "-" + Guid.NewGuid();
+
+ const string applicationId = "blender";
+
+ /*Func test = async () =>
+ {*/
+ using (BatchClient client = await TestUtilities.OpenBatchClientFromEnvironmentAsync().ConfigureAwait(false))
+ {
+
+ var poolInfo = new PoolInformation
+ {
+ AutoPoolSpecification = new AutoPoolSpecification
+ {
+ PoolSpecification = new PoolSpecification
+ {
+ CloudServiceConfiguration = new CloudServiceConfiguration(PoolFixture.OSFamily),
+ VirtualMachineSize = PoolFixture.VMSize,
+ },
+ PoolLifetimeOption = PoolLifetimeOption.Job
+ }
+ };
+
+ CloudJob response = null;
+ try
+ {
+ //List jobs = await client.JobOperations.ListJobs().ToListAsync();
+
+ CloudJob job = client.JobOperations.CreateJob(jobId, poolInfo);
+ job.JobManagerTask = new JobManagerTask { ApplicationPackageReferences = new []{ new ApplicationPackageReference
+ {
+ ApplicationId = applicationId,
+ Version = PoolFixture.VMSize
+ }}};
+
+ await job.CommitAsync().ConfigureAwait(false);
+
+ response = await client.JobOperations.GetJobAsync(jobId).ConfigureAwait(false);
+
+ Assert.NotNull(response);
+
+ //Assert.Equal(applicationId, response.JobManagerTask.ApplicationPackageReferences.First().ApplicationId);
+
+ }
+ catch(Exception exception)
+ {
+ throw exception;
+ }
+ finally
+ {
+ if (response != null)
+ {
+ TestUtilities.DeleteJobIfExistsAsync(client, jobId).Wait();
+ }
+ }
+ }
+ //};
+ //await SynchronizationContextHelper.RunTestAsync(test, TestTimeout);
+ }
+ }
+
+ public abstract class BatchCustomClientBehavior : RequestInterceptor
+ {
+ public BatchCustomClientBehavior():base()
+ {
+ }
+
+ public static void Dosomthing(IBatchRequest request)
+ {
+ }
+ }
+}