/// <summary>
 /// The Get Operation Status operation returns the status of the
 /// specified operation. After calling an asynchronous operation, you
 /// can call Get Operation Status to determine whether the operation
 /// has succeeded, failed, or is still in progress.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Automation.IAutomationManagementClient.
 /// </param>
 /// <param name='operationStatusLink'>
 /// Required. Location value returned by the Begin operation.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static LongRunningOperationResultResponse GetOperationResultStatus(this IAutomationManagementClient operations, string operationStatusLink)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IAutomationManagementClient)s).GetOperationResultStatusAsync(operationStatusLink);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
コード例 #2
0
        public AutomationClient(
            WindowsAzureSubscription subscription,
            IAutomationManagementClient automationManagementClient)
        {
            Requires.Argument("automationManagementClient", automationManagementClient).NotNull();

            this.Subscription = subscription;
            this.automationManagementClient = automationManagementClient;
        }
コード例 #3
0
        public AutomationClient(
            WindowsAzureSubscription subscription,
            IAutomationManagementClient automationManagementClient)
        {
            Requires.Argument("automationManagementClient", automationManagementClient).NotNull();

            this.Subscription = subscription;
            this.automationManagementClient = automationManagementClient;
        }
コード例 #4
0
        public RequestSettings(IAutomationManagementClient automationClient)
        {
            client = ((AutomationManagementClient)automationClient);
            client.HttpClient.DefaultRequestHeaders.Remove(Constants.ClientRequestIdHeaderName);
            client.HttpClient.DefaultRequestHeaders.Add(Constants.ClientRequestIdHeaderName, Guid.NewGuid().ToString());

            client.HttpClient.DefaultRequestHeaders.Remove(Constants.ActivityIdHeaderName);
            var activityId = Guid.NewGuid();
            EventProvider.SetActivityId(ref activityId);
            client.HttpClient.DefaultRequestHeaders.Add(Constants.ActivityIdHeaderName, activityId.ToString());
        }
コード例 #5
0
        public RequestSettings(IAutomationManagementClient automationClient)
        {
            client = ((AutomationManagementClient)automationClient);
            client.HttpClient.DefaultRequestHeaders.Remove(Constants.ClientRequestIdHeaderName);
            client.HttpClient.DefaultRequestHeaders.Add(Constants.ClientRequestIdHeaderName, Guid.NewGuid().ToString());

            client.HttpClient.DefaultRequestHeaders.Remove(Constants.ActivityIdHeaderName);
            var activityId = Guid.NewGuid();

            EventProvider.SetActivityId(ref activityId);
            client.HttpClient.DefaultRequestHeaders.Add(Constants.ActivityIdHeaderName, activityId.ToString());
        }
        public static void DeleteAutomationAccount(this IAutomationManagementClient client, string automationAccountName)
        {
            if (automationAccountName == null)
            {
                throw new ArgumentNullException("automationAccountName");
            }

            var cloudServices = client.CloudServices.List().CloudServices;

            foreach (var cloudService in cloudServices)
            {
                if (cloudService.Resources.Any(resource => 0 == String.Compare(resource.Name, automationAccountName, CultureInfo.InvariantCulture,
                                                                               CompareOptions.IgnoreCase)))
                {
                    client.AutomationAccounts.Delete(cloudService.Name, automationAccountName);
                    return;
                }
            }
        }
        public static void CreateAutomationAccount(this IAutomationManagementClient client, string automationAccountName, string location)
        {
            if (automationAccountName == null)
            {
                throw new ArgumentNullException("automationAccountName");
            }

            if (location == null)
            {
                throw new ArgumentNullException("location");
            }

            var generatedCsName = string.Format(CultureInfo.InvariantCulture, "OaasCS{0}-{1}", client.Credentials.SubscriptionId, location.Replace(' ', '-'));

            try
            {
                client.CloudServices.Create(
                    new CloudServiceCreateParameters()
                {
                    Name        = generatedCsName,
                    GeoRegion   = location,
                    Label       = generatedCsName,
                    Description = "Cloud Service created via SDK client"
                });
            }
            catch (CloudException)
            {
                // Ignore create cloud service error
            }

            client.AutomationAccounts.Create(generatedCsName,
                                             new AutomationAccountCreateParameters()
            {
                Name = automationAccountName,
                CloudServiceSettings = new CloudServiceSettings
                {
                    GeoRegion = location
                },
            });
        }
コード例 #8
0
 public RequestSettings(IAutomationManagementClient automationClient)
 {
     client = ((AutomationManagementClient)automationClient);
     client.HttpClient.DefaultRequestHeaders.Remove(Constants.ClientRequestIdHeaderName);
     client.HttpClient.DefaultRequestHeaders.Add(Constants.ClientRequestIdHeaderName, Guid.NewGuid().ToString());
 }
コード例 #9
0
 public RequestSettings(IAutomationManagementClient automationClient)
 {
     client = ((AutomationManagementClient)automationClient);
     client.HttpClient.DefaultRequestHeaders.Remove(Constants.ClientRequestIdHeaderName);
     client.HttpClient.DefaultRequestHeaders.Add(Constants.ClientRequestIdHeaderName, Guid.NewGuid().ToString());
 }
 /// <summary>
 /// The Get Operation Status operation returns the status of the
 /// specified operation. After calling an asynchronous operation, you
 /// can call Get Operation Status to determine whether the operation
 /// has succeeded, failed, or is still in progress.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Automation.IAutomationManagementClient.
 /// </param>
 /// <param name='operationStatusLink'>
 /// Required. Location value returned by the Begin operation.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static Task <LongRunningOperationResultResponse> GetOperationResultStatusAsync(this IAutomationManagementClient operations, string operationStatusLink)
 {
     return(operations.GetOperationResultStatusAsync(operationStatusLink, CancellationToken.None));
 }
 /// <summary>
 /// The Get Operation Status operation returns the status of
 /// thespecified operation. After calling an asynchronous operation,
 /// you can call Get Operation Status to determine whether the
 /// operation has succeeded, failed, or is still in progress.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Automation.IAutomationManagementClient.
 /// </param>
 /// <param name='requestId'>
 /// Required. The request ID for the request you wish to track. The
 /// request ID is returned in the x-ms-request-id response header for
 /// every request.
 /// </param>
 /// <returns>
 /// The response body contains the status of the specified asynchronous
 /// operation, indicating whether it has succeeded, is inprogress, or
 /// has failed. Note that this status is distinct from the HTTP status
 /// code returned for the Get Operation Status operation itself.  If
 /// the asynchronous operation succeeded, the response body includes
 /// the HTTP status code for the successful request.  If the
 /// asynchronous operation failed, the response body includes the HTTP
 /// status code for the failed request, and also includes error
 /// information regarding the failure.
 /// </returns>
 public static Task <LongRunningOperationStatusResponse> GetOperationStatusAsync(this IAutomationManagementClient operations, string requestId)
 {
     return(operations.GetOperationStatusAsync(requestId, CancellationToken.None));
 }