你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
BatchClient.ReplacePoolPropertiesAsync 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
ReplacePoolPropertiesAsync(String, BatchPoolReplaceContent, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken) |
Updates the properties of the specified Pool. |
ReplacePoolPropertiesAsync(String, RequestContent, Nullable<Int32>, Nullable<DateTimeOffset>, RequestContext) |
[Protocol Method] Updates the properties of the specified Pool.
|
ReplacePoolPropertiesAsync(String, BatchPoolReplaceContent, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken)
- Source:
- BatchClientCustom.cs
Updates the properties of the specified Pool.
public virtual System.Threading.Tasks.Task<Azure.Response> ReplacePoolPropertiesAsync (string poolId, Azure.Compute.Batch.BatchPoolReplaceContent pool, int? timeOutInSeconds = default, DateTimeOffset? ocpdate = default, System.Threading.CancellationToken cancellationToken = default);
abstract member ReplacePoolPropertiesAsync : string * Azure.Compute.Batch.BatchPoolReplaceContent * Nullable<int> * Nullable<DateTimeOffset> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
override this.ReplacePoolPropertiesAsync : string * Azure.Compute.Batch.BatchPoolReplaceContent * Nullable<int> * Nullable<DateTimeOffset> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function ReplacePoolPropertiesAsync (poolId As String, pool As BatchPoolReplaceContent, Optional timeOutInSeconds As Nullable(Of Integer) = Nothing, Optional ocpdate As Nullable(Of DateTimeOffset) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response)
Parameters
- poolId
- String
The ID of the Pool to update.
The options to use for replacing properties on the pool.
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
poolId
or pool
is null.
poolId
is an empty string, and was expected to be non-empty.
Examples
This sample shows how to call ReplacePoolPropertiesAsync.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchPoolReplaceContent pool = new BatchPoolReplaceContent(new BatchApplicationPackageReference[]
{
new BatchApplicationPackageReference("<applicationId>")
}, new MetadataItem[]
{
new MetadataItem("<name>", "<value>")
});
Response response = await client.ReplacePoolPropertiesAsync("<poolId>", pool);
This sample shows how to call ReplacePoolPropertiesAsync with all parameters.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchPoolReplaceContent pool = new BatchPoolReplaceContent(new BatchApplicationPackageReference[]
{
new BatchApplicationPackageReference("<applicationId>")
{
Version = "<version>",
}
}, new MetadataItem[]
{
new MetadataItem("<name>", "<value>")
})
{
StartTask = new BatchStartTask("<commandLine>")
{
ContainerSettings = new BatchTaskContainerSettings("<imageName>")
{
ContainerRunOptions = "<containerRunOptions>",
Registry = new ContainerRegistryReference
{
Username = "<username>",
Password = "<password>",
RegistryServer = "<registryServer>",
IdentityReference = new BatchNodeIdentityReference
{
ResourceId = "<resourceId>",
},
},
WorkingDirectory = ContainerWorkingDirectory.TaskWorkingDirectory,
},
ResourceFiles = {new ResourceFile
{
AutoStorageContainerName = "<autoStorageContainerName>",
StorageContainerUrl = "<storageContainerUrl>",
HttpUrl = "<httpUrl>",
BlobPrefix = "<blobPrefix>",
FilePath = "<filePath>",
FileMode = "<fileMode>",
IdentityReference = default,
}},
EnvironmentSettings = {new EnvironmentSetting("<name>")
{
Value = "<value>",
}},
UserIdentity = new UserIdentity
{
Username = "<username>",
AutoUser = new AutoUserSpecification
{
Scope = AutoUserScope.Task,
ElevationLevel = ElevationLevel.NonAdmin,
},
},
MaxTaskRetryCount = 1234,
WaitForSuccess = true,
},
TargetNodeCommunicationMode = BatchNodeCommunicationMode.Default,
};
Response response = await client.ReplacePoolPropertiesAsync("<poolId>", pool, timeOutInSeconds: 1234, ocpdate: DateTimeOffset.Parse("Tue, 10 May 2022 18:57:31 GMT"));
Remarks
This fully replaces all the updatable properties of the Pool. For example, if the Pool has a StartTask associated with it and if StartTask is not specified with this request, then the Batch service will remove the existing StartTask.
Applies to
ReplacePoolPropertiesAsync(String, RequestContent, Nullable<Int32>, Nullable<DateTimeOffset>, RequestContext)
- Source:
- BatchClientCustom.cs
[Protocol Method] Updates the properties of the specified Pool.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler ReplacePoolPropertiesAsync(String, BatchPoolReplaceContent, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> ReplacePoolPropertiesAsync (string poolId, Azure.Core.RequestContent content, int? timeOutInSeconds = default, DateTimeOffset? ocpdate = default, Azure.RequestContext context = default);
abstract member ReplacePoolPropertiesAsync : string * Azure.Core.RequestContent * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.ReplacePoolPropertiesAsync : string * Azure.Core.RequestContent * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function ReplacePoolPropertiesAsync (poolId As String, 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
- poolId
- String
The ID of the Pool to update.
- 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
poolId
or content
is null.
poolId
is an empty string, and was expected to be non-empty.
Service returned a non-success status code.
Examples
This sample shows how to call ReplacePoolPropertiesAsync.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
applicationPackageReferences = new object[]
{
new
{
applicationId = "<applicationId>",
}
},
metadata = new object[]
{
new
{
name = "<name>",
value = "<value>",
}
},
});
Response response = await client.ReplacePoolPropertiesAsync("<poolId>", content);
Console.WriteLine(response.Status);
This sample shows how to call ReplacePoolPropertiesAsync with all parameters and request content.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
startTask = new
{
commandLine = "<commandLine>",
containerSettings = new
{
containerRunOptions = "<containerRunOptions>",
imageName = "<imageName>",
registry = new
{
username = "<username>",
password = "<password>",
registryServer = "<registryServer>",
identityReference = new
{
resourceId = "<resourceId>",
},
},
workingDirectory = "taskWorkingDirectory",
},
resourceFiles = new object[]
{
new
{
autoStorageContainerName = "<autoStorageContainerName>",
storageContainerUrl = "<storageContainerUrl>",
httpUrl = "<httpUrl>",
blobPrefix = "<blobPrefix>",
filePath = "<filePath>",
fileMode = "<fileMode>",
}
},
environmentSettings = new object[]
{
new
{
name = "<name>",
value = "<value>",
}
},
userIdentity = new
{
username = "<username>",
autoUser = new
{
scope = "task",
elevationLevel = "nonadmin",
},
},
maxTaskRetryCount = 1234,
waitForSuccess = true,
},
applicationPackageReferences = new object[]
{
new
{
applicationId = "<applicationId>",
version = "<version>",
}
},
metadata = new object[]
{
new
{
name = "<name>",
value = "<value>",
}
},
targetNodeCommunicationMode = "default",
});
Response response = await client.ReplacePoolPropertiesAsync("<poolId>", content, timeOutInSeconds: 1234, ocpdate: DateTimeOffset.Parse("Tue, 10 May 2022 18:57:31 GMT"));
Console.WriteLine(response.Status);