BatchClient.CreateJobScheduleAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CreateJobScheduleAsync(BatchJobScheduleCreateContent, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken) |
Creates a Job Schedule to the specified Account. |
CreateJobScheduleAsync(RequestContent, Nullable<Int32>, Nullable<DateTimeOffset>, RequestContext) |
[Protocol Method] Creates a Job Schedule to the specified Account.
|
CreateJobScheduleAsync(BatchJobScheduleCreateContent, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken)
- Source:
- BatchClientCustom.cs
Creates a Job Schedule to the specified Account.
public virtual System.Threading.Tasks.Task<Azure.Response> CreateJobScheduleAsync(Azure.Compute.Batch.BatchJobScheduleCreateContent jobSchedule, int? timeOutInSeconds = default, DateTimeOffset? ocpdate = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateJobScheduleAsync : Azure.Compute.Batch.BatchJobScheduleCreateContent * Nullable<int> * Nullable<DateTimeOffset> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
override this.CreateJobScheduleAsync : Azure.Compute.Batch.BatchJobScheduleCreateContent * Nullable<int> * Nullable<DateTimeOffset> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function CreateJobScheduleAsync (jobSchedule As BatchJobScheduleCreateContent, Optional timeOutInSeconds As Nullable(Of Integer) = Nothing, Optional ocpdate As Nullable(Of DateTimeOffset) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response)
Parameters
- jobSchedule
- BatchJobScheduleCreateContent
The Job Schedule to be created.
The maximum time that the server can spend processing the request, in seconds. The default is 30 seconds. If the value is larger than 30, the default will be used instead.".
- ocpdate
- Nullable<DateTimeOffset>
The time the request was issued. Client libraries typically set this to the current system clock time; set it explicitly if you are calling the REST API directly.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
jobSchedule
is null.
Examples
This sample shows how to call CreateJobScheduleAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchJobScheduleCreateContent jobSchedule = new BatchJobScheduleCreateContent("jobScheduleId", new BatchJobScheduleConfiguration
{
RecurrenceInterval = XmlConvert.ToTimeSpan("PT5M"),
}, new BatchJobSpecification(new BatchPoolInfo
{
PoolId = "poolId",
}));
Response response = await client.CreateJobScheduleAsync(jobSchedule);
This sample shows how to call CreateJobScheduleAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchJobScheduleCreateContent jobSchedule = new BatchJobScheduleCreateContent("jobScheduleId", new BatchJobScheduleConfiguration
{
DoNotRunUntil = DateTimeOffset.Parse("2014-09-10T02:30:00.000Z"),
DoNotRunAfter = DateTimeOffset.Parse("2014-09-10T06:30:00.000Z"),
StartWindow = XmlConvert.ToTimeSpan("PT1M"),
RecurrenceInterval = XmlConvert.ToTimeSpan("PT5M"),
}, new BatchJobSpecification(new BatchPoolInfo
{
AutoPoolSpecification = new BatchAutoPoolSpecification(BatchPoolLifetimeOption.JobSchedule)
{
AutoPoolIdPrefix = "mypool",
Pool = new BatchPoolSpecification("STANDARD_D2S_V3")
{
VirtualMachineConfiguration = new VirtualMachineConfiguration(new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-datacenter-smalldisk",
Version = "latest",
}, "batch.node.windows amd64")
{
WindowsConfiguration = new WindowsConfiguration
{
EnableAutomaticUpdates = false,
},
NodePlacementConfiguration = new BatchNodePlacementConfiguration
{
Policy = BatchNodePlacementPolicyType.Zonal,
},
},
TaskSlotsPerNode = 2,
TaskSchedulingPolicy = new BatchTaskSchedulingPolicy(BatchNodeFillType.Spread),
ResizeTimeout = XmlConvert.ToTimeSpan("PT15M"),
TargetDedicatedNodes = 3,
TargetLowPriorityNodes = 0,
EnableAutoScale = false,
EnableInterNodeCommunication = true,
StartTask = new BatchStartTask("myprogram2.exe")
{
ResourceFiles = {new ResourceFile
{
HttpUrl = "http://mystorage1.blob.core.windows.net/scripts/myprogram2.exe?sas",
FilePath = "myprogram2.exe",
}},
EnvironmentSettings = {new EnvironmentSetting("myvariable")
{
Value = "myvalue",
}},
UserIdentity = new UserIdentity
{
AutoUser = new AutoUserSpecification
{
Scope = AutoUserScope.Task,
ElevationLevel = ElevationLevel.Admin,
},
},
MaxTaskRetryCount = 2,
WaitForSuccess = true,
},
CertificateReferences = {new BatchCertificateReference("0123456789abcdef0123456789abcdef01234567", "sha1")
{
StoreLocation = BatchCertificateStoreLocation.LocalMachine,
StoreName = "Root",
Visibility = {BatchCertificateVisibility.Task},
}},
Metadata = { new MetadataItem("myproperty", "myvalue") },
TargetNodeCommunicationMode = BatchNodeCommunicationMode.Default,
},
},
})
{
Priority = 100,
Constraints = new BatchJobConstraints
{
MaxWallClockTime = XmlConvert.ToTimeSpan("PT1H"),
MaxTaskRetryCount = -1,
},
JobManagerTask = new BatchJobManagerTask("mytask1", "myprogram.exe")
{
ResourceFiles = {new ResourceFile
{
HttpUrl = "http://mystorage1.blob.core.windows.net/scripts/myprogram.exe?sas",
FilePath = "myprogram.exe",
}, new ResourceFile
{
HttpUrl = "http://mystorage1.blob.core.windows.net/scripts/test.txt?sas",
FilePath = "test.txt",
}},
EnvironmentSettings = {new EnvironmentSetting("myvariable")
{
Value = "myvalue",
}},
Constraints = new BatchTaskConstraints
{
MaxWallClockTime = XmlConvert.ToTimeSpan("PT1H"),
RetentionTime = XmlConvert.ToTimeSpan("PT1H"),
MaxTaskRetryCount = 0,
},
RequiredSlots = 2,
KillJobOnCompletion = true,
UserIdentity = new UserIdentity
{
AutoUser = new AutoUserSpecification
{
Scope = AutoUserScope.Task,
ElevationLevel = ElevationLevel.NonAdmin,
},
},
RunExclusive = true,
},
})
{
Metadata = { new MetadataItem("myproperty", "myvalue") },
};
Response response = await client.CreateJobScheduleAsync(jobSchedule);
Applies to
CreateJobScheduleAsync(RequestContent, Nullable<Int32>, Nullable<DateTimeOffset>, RequestContext)
- Source:
- BatchClientCustom.cs
[Protocol Method] Creates a Job Schedule to the specified Account.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler CreateJobScheduleAsync(BatchJobScheduleCreateContent, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> CreateJobScheduleAsync(Azure.Core.RequestContent content, int? timeOutInSeconds = default, DateTimeOffset? ocpdate = default, Azure.RequestContext context = default);
abstract member CreateJobScheduleAsync : Azure.Core.RequestContent * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.CreateJobScheduleAsync : Azure.Core.RequestContent * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function CreateJobScheduleAsync (content As RequestContent, Optional timeOutInSeconds As Nullable(Of Integer) = Nothing, Optional ocpdate As Nullable(Of DateTimeOffset) = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)
Parameters
- content
- RequestContent
The content to send as the body of the request.
The maximum time that the server can spend processing the request, in seconds. The default is 30 seconds. If the value is larger than 30, the default will be used instead.".
- ocpdate
- Nullable<DateTimeOffset>
The time the request was issued. Client libraries typically set this to the current system clock time; set it explicitly if you are calling the REST API directly.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
content
is null.
Service returned a non-success status code.
Examples
This sample shows how to call CreateJobScheduleAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
id = "jobScheduleId",
schedule = new
{
recurrenceInterval = "PT5M",
},
jobSpecification = new
{
poolInfo = new
{
poolId = "poolId",
},
},
});
Response response = await client.CreateJobScheduleAsync(content);
Console.WriteLine(response.Status);
This sample shows how to call CreateJobScheduleAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
id = "jobScheduleId",
schedule = new
{
doNotRunUntil = "2014-09-10T02:30:00.000Z",
doNotRunAfter = "2014-09-10T06:30:00.000Z",
startWindow = "PT1M",
recurrenceInterval = "PT5M",
},
jobSpecification = new
{
priority = 100,
constraints = new
{
maxWallClockTime = "PT1H",
maxTaskRetryCount = -1,
},
jobManagerTask = new
{
id = "mytask1",
commandLine = "myprogram.exe",
resourceFiles = new object[]
{
new
{
httpUrl = "http://mystorage1.blob.core.windows.net/scripts/myprogram.exe?sas",
filePath = "myprogram.exe",
},
new
{
httpUrl = "http://mystorage1.blob.core.windows.net/scripts/test.txt?sas",
filePath = "test.txt",
}
},
environmentSettings = new object[]
{
new
{
name = "myvariable",
value = "myvalue",
}
},
constraints = new
{
maxWallClockTime = "PT1H",
maxTaskRetryCount = 0,
retentionTime = "PT1H",
},
requiredSlots = 2,
killJobOnCompletion = true,
userIdentity = new
{
autoUser = new
{
scope = "task",
elevationLevel = "nonadmin",
},
},
runExclusive = true,
},
poolInfo = new
{
autoPoolSpecification = new
{
autoPoolIdPrefix = "mypool",
poolLifetimeOption = "jobschedule",
pool = new
{
vmSize = "STANDARD_D2S_V3",
virtualMachineConfiguration = new
{
imageReference = new
{
publisher = "MicrosoftWindowsServer",
offer = "WindowsServer",
sku = "2016-datacenter-smalldisk",
version = "latest",
},
nodeAgentSKUId = "batch.node.windows amd64",
windowsConfiguration = new
{
enableAutomaticUpdates = false,
},
nodePlacementConfiguration = new
{
policy = "zonal",
},
},
resizeTimeout = "PT15M",
targetDedicatedNodes = 3,
targetLowPriorityNodes = 0,
taskSlotsPerNode = 2,
taskSchedulingPolicy = new
{
nodeFillType = "spread",
},
enableAutoScale = false,
enableInterNodeCommunication = true,
startTask = new
{
commandLine = "myprogram2.exe",
resourceFiles = new object[]
{
new
{
httpUrl = "http://mystorage1.blob.core.windows.net/scripts/myprogram2.exe?sas",
filePath = "myprogram2.exe",
}
},
environmentSettings = new object[]
{
new
{
name = "myvariable",
value = "myvalue",
}
},
userIdentity = new
{
autoUser = new
{
scope = "task",
elevationLevel = "admin",
},
},
maxTaskRetryCount = 2,
waitForSuccess = true,
},
certificateReferences = new object[]
{
new
{
thumbprint = "0123456789abcdef0123456789abcdef01234567",
thumbprintAlgorithm = "sha1",
storeLocation = "localmachine",
storeName = "Root",
visibility = new object[]
{
"task"
},
}
},
metadata = new object[]
{
new
{
name = "myproperty",
value = "myvalue",
}
},
targetNodeCommunicationMode = "default",
},
},
},
},
metadata = new object[]
{
new
{
name = "myproperty",
value = "myvalue",
}
},
});
Response response = await client.CreateJobScheduleAsync(content);
Console.WriteLine(response.Status);
Applies to
Azure SDK for .NET