다음을 통해 공유


BatchClient.ReplacePoolProperties Method

Definition

Overloads

ReplacePoolProperties(String, BatchPoolReplaceContent, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken)

Updates the properties of the specified Pool.

ReplacePoolProperties(String, RequestContent, Nullable<Int32>, Nullable<DateTimeOffset>, RequestContext)

[Protocol Method] Updates the properties of the specified Pool.

ReplacePoolProperties(String, BatchPoolReplaceContent, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken)

Source:
BatchClient.cs

Updates the properties of the specified Pool.

public virtual Azure.Response ReplacePoolProperties (string poolId, Azure.Compute.Batch.BatchPoolReplaceContent pool, int? timeOutInSeconds = default, DateTimeOffset? ocpdate = default, System.Threading.CancellationToken cancellationToken = default);
abstract member ReplacePoolProperties : string * Azure.Compute.Batch.BatchPoolReplaceContent * Nullable<int> * Nullable<DateTimeOffset> * System.Threading.CancellationToken -> Azure.Response
override this.ReplacePoolProperties : string * Azure.Compute.Batch.BatchPoolReplaceContent * Nullable<int> * Nullable<DateTimeOffset> * System.Threading.CancellationToken -> Azure.Response
Public Overridable Function ReplacePoolProperties (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 Response

Parameters

poolId
String

The ID of the Pool to update.

pool
BatchPoolReplaceContent

The options to use for replacing properties on the pool.

timeOutInSeconds
Nullable<Int32>

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 ReplacePoolProperties.

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 = client.ReplacePoolProperties("<poolId>", pool);

This sample shows how to call ReplacePoolProperties 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 = client.ReplacePoolProperties("<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

ReplacePoolProperties(String, RequestContent, Nullable<Int32>, Nullable<DateTimeOffset>, RequestContext)

Source:
BatchClient.cs

[Protocol Method] Updates the properties of the specified Pool.

public virtual Azure.Response ReplacePoolProperties (string poolId, Azure.Core.RequestContent content, int? timeOutInSeconds = default, DateTimeOffset? ocpdate = default, Azure.RequestContext context = default);
abstract member ReplacePoolProperties : string * Azure.Core.RequestContent * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestContext -> Azure.Response
override this.ReplacePoolProperties : string * Azure.Core.RequestContent * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestContext -> Azure.Response
Public Overridable Function ReplacePoolProperties (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 Response

Parameters

poolId
String

The ID of the Pool to update.

content
RequestContent

The content to send as the body of the request.

timeOutInSeconds
Nullable<Int32>

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 ReplacePoolProperties.

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 = client.ReplacePoolProperties("<poolId>", content);

Console.WriteLine(response.Status);

This sample shows how to call ReplacePoolProperties 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 = client.ReplacePoolProperties("<poolId>", content, timeOutInSeconds: 1234, ocpdate: DateTimeOffset.Parse("Tue, 10 May 2022 18:57:31 GMT"));

Console.WriteLine(response.Status);

Applies to