コード例 #1
0
        public void CanUpdatePoolByDeletingAppPkgRefs()
        {
            var poolId = Guid.NewGuid().ToString();
            var client = new BatchServiceClient(new Uri(Url), new BatchSharedKeyCredential(AccountName, AccountKey));

            var poolAddParameter = new PoolAddParameter(poolId, "small", "4");

            poolAddParameter.ApplicationPackageReferences = new[]
            {
                new ApplicationPackageReference {
                    ApplicationId = AppPackageIdOne, Version = "1.0"
                },
                new ApplicationPackageReference {
                    ApplicationId = AppPackageIdTwo
                },
            };
            try
            {
                client.Pool.AddAsync(poolAddParameter).Wait();

                var updateParams = new PoolUpdatePropertiesParameter(
                    new List <CertificateReference>(),
                    new List <ApplicationPackageReference>(),
                    new List <MetadataItem>());

                var updateResponse = client.Pool.UpdatePropertiesWithHttpMessagesAsync(poolId, updateParams).Result;
                Assert.Equal(HttpStatusCode.NoContent, updateResponse.Response.StatusCode);

                var pool = client.Pool.GetAsync(poolId).Result;

                Assert.Equal(poolId, pool.Id);
                Assert.Null(pool.ApplicationPackageReferences);
            }
            finally
            {
                TestUtilities.DeletePoolIfExistsNoThrow(client, poolId, output);
            }
        }
コード例 #2
0
 public virtual Response UpdateProperties(string poolId, PoolUpdatePropertiesParameter poolUpdatePropertiesParameter, PoolUpdatePropertiesOptions poolUpdatePropertiesOptions, CancellationToken cancellationToken = default)
 {
     return(RestClient.UpdateProperties(poolId, poolUpdatePropertiesParameter, poolUpdatePropertiesOptions, cancellationToken).GetRawResponse());
 }
コード例 #3
0
 public virtual async Task <Response> UpdatePropertiesAsync(string poolId, PoolUpdatePropertiesParameter poolUpdatePropertiesParameter, PoolUpdatePropertiesOptions poolUpdatePropertiesOptions, CancellationToken cancellationToken = default)
 {
     return((await RestClient.UpdatePropertiesAsync(poolId, poolUpdatePropertiesParameter, poolUpdatePropertiesOptions, cancellationToken).ConfigureAwait(false)).GetRawResponse());
 }
コード例 #4
0
 /// <summary>
 /// Updates the properties of the specified Pool.
 /// </summary>
 /// <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.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='poolId'>
 /// The ID of the Pool to update.
 /// </param>
 /// <param name='poolUpdatePropertiesParameter'>
 /// The parameters for the request.
 /// </param>
 /// <param name='poolUpdatePropertiesOptions'>
 /// Additional parameters for the operation
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <PoolUpdatePropertiesHeaders> UpdatePropertiesAsync(this IPoolOperations operations, string poolId, PoolUpdatePropertiesParameter poolUpdatePropertiesParameter, PoolUpdatePropertiesOptions poolUpdatePropertiesOptions = default(PoolUpdatePropertiesOptions), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdatePropertiesWithHttpMessagesAsync(poolId, poolUpdatePropertiesParameter, poolUpdatePropertiesOptions, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Headers);
     }
 }
コード例 #5
0
 /// <summary>
 /// Updates the properties of the specified Pool.
 /// </summary>
 /// <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.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='poolId'>
 /// The ID of the Pool to update.
 /// </param>
 /// <param name='poolUpdatePropertiesParameter'>
 /// The parameters for the request.
 /// </param>
 /// <param name='poolUpdatePropertiesOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static PoolUpdatePropertiesHeaders UpdateProperties(this IPoolOperations operations, string poolId, PoolUpdatePropertiesParameter poolUpdatePropertiesParameter, PoolUpdatePropertiesOptions poolUpdatePropertiesOptions = default(PoolUpdatePropertiesOptions))
 {
     return(operations.UpdatePropertiesAsync(poolId, poolUpdatePropertiesParameter, poolUpdatePropertiesOptions).GetAwaiter().GetResult());
 }
コード例 #6
0
 /// <summary>
 /// Updates the properties of a pool.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='poolId'>
 /// The id of the pool to update.
 /// </param>
 /// <param name='poolUpdatePropertiesParameter'>
 /// The parameters for the request.
 /// </param>
 /// <param name='poolUpdatePropertiesOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static PoolUpdatePropertiesHeaders UpdateProperties(this IPoolOperations operations, string poolId, PoolUpdatePropertiesParameter poolUpdatePropertiesParameter, PoolUpdatePropertiesOptions poolUpdatePropertiesOptions = default(PoolUpdatePropertiesOptions))
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IPoolOperations)s).UpdatePropertiesAsync(poolId, poolUpdatePropertiesParameter, poolUpdatePropertiesOptions), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
コード例 #7
0
        public void SetBatchPoolParametersGetPassedToRequestTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            cmdlet.Pool = new PSCloudPool(BatchTestHelpers.CreateFakeBoundPool(context));

            // Update the pool
            cmdlet.Pool.StartTask             = new PSStartTask("cmd /c echo start task");
            cmdlet.Pool.CertificateReferences = new List <PSCertificateReference>()
            {
                new PSCertificateReference()
                {
                    StoreLocation       = Azure.Batch.Common.CertStoreLocation.LocalMachine,
                    Thumbprint          = "thumbprint",
                    ThumbprintAlgorithm = "sha1",
                    StoreName           = "My",
                    Visibility          = Azure.Batch.Common.CertificateVisibility.StartTask
                }
            };
            cmdlet.Pool.ApplicationPackageReferences = new List <PSApplicationPackageReference>()
            {
                new PSApplicationPackageReference()
                {
                    ApplicationId = "myApp",
                    Version       = "1.0"
                }
            };
            cmdlet.Pool.Metadata = new List <PSMetadataItem>()
            {
                new PSMetadataItem("meta1", "value1")
            };

            PoolUpdatePropertiesParameter requestParameters = null;

            // Store the request parameters
            RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor <
                PoolUpdatePropertiesParameter,
                PoolUpdatePropertiesOptions,
                AzureOperationHeaderResponse <PoolUpdatePropertiesHeaders> >(requestAction: (r) =>
            {
                requestParameters = r.Parameters;
            });

            cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>()
            {
                interceptor
            };
            cmdlet.ExecuteCmdlet();

            // Verify the request parameters match the cmdlet parameters
            Assert.Equal(cmdlet.Pool.StartTask.CommandLine, requestParameters.StartTask.CommandLine);
            Assert.Equal(cmdlet.Pool.CertificateReferences.Count, requestParameters.CertificateReferences.Count);
            Assert.Equal(cmdlet.Pool.CertificateReferences[0].StoreName, requestParameters.CertificateReferences[0].StoreName);
            Assert.Equal(cmdlet.Pool.CertificateReferences[0].Thumbprint, requestParameters.CertificateReferences[0].Thumbprint);
            Assert.Equal(cmdlet.Pool.CertificateReferences[0].ThumbprintAlgorithm, requestParameters.CertificateReferences[0].ThumbprintAlgorithm);
            Assert.Equal(cmdlet.Pool.ApplicationPackageReferences.Count, requestParameters.ApplicationPackageReferences.Count);
            Assert.Equal(cmdlet.Pool.ApplicationPackageReferences[0].ApplicationId, requestParameters.ApplicationPackageReferences[0].ApplicationId);
            Assert.Equal(cmdlet.Pool.ApplicationPackageReferences[0].Version, requestParameters.ApplicationPackageReferences[0].Version);
            Assert.Equal(cmdlet.Pool.Metadata.Count, requestParameters.Metadata.Count);
            Assert.Equal(cmdlet.Pool.Metadata[0].Name, requestParameters.Metadata[0].Name);
            Assert.Equal(cmdlet.Pool.Metadata[0].Value, requestParameters.Metadata[0].Value);
        }