/// <inheritdoc cref="AzurePSCmdlet.ExecuteCmdlet"/> public override void ExecuteCmdlet() { if (!ShouldProcess(Instance, Resources.RestartingAnalysisServicesServer)) { return; } var restartEndpoint = string.Format(AsAzureEndpoints.RestartEndpointPathFormat, ServerName); using (var message = AsAzureDataplaneClient.CallPostAsync(restartEndpoint).Result) { message.EnsureSuccessStatusCode(); if (PassThru.IsPresent) { WriteObject(true); } } }
/// <summary> /// Worker Method for the synchronize request. /// </summary> /// <param name="syncBaseUri">Base Uri for sync</param> /// <param name="databaseName">Database name</param> /// <returns></returns> private async Task <ScaleOutServerDatabaseSyncDetails> SynchronizeDatabaseAsync( Uri syncBaseUri, string databaseName) { Tuple <Uri, RetryConditionHeaderValue> pollingUrlAndRetryAfter = new Tuple <Uri, RetryConditionHeaderValue>(null, null); ScaleOutServerDatabaseSyncDetails syncResult = null; return(await Task.Run(async() => { var syncEndpoint = string.Format(AsAzureEndpoints.SynchronizeEndpointPathFormat, this.ServerName, databaseName); this.AsAzureDataplaneClient.ResetHttpClient(); using (var message = await AsAzureDataplaneClient.CallPostAsync(syncBaseUri, syncEndpoint, correlationId)) { this.syncRequestRootActivityId = message.Headers.Contains(RootActivityIdHeaderName) ? message.Headers.GetValues(RootActivityIdHeaderName).FirstOrDefault() : string.Empty; this.syncRequestTimeStamp = message.Headers.Contains(CurrentUtcDateHeaderName) ? message.Headers.GetValues(CurrentUtcDateHeaderName).FirstOrDefault() : string.Empty; if (message.StatusCode != HttpStatusCode.Accepted) { var timestampNow = DateTime.Now; // Return sync details with exception message as details return new ScaleOutServerDatabaseSyncDetails { CorrelationId = correlationId.ToString(), Database = databaseName, SyncState = DatabaseSyncState.Invalid, Details = Resources.PostSyncRequestFailureMessage.FormatInvariant( ServerName, this.syncRequestRootActivityId, this.syncRequestTimeStamp, await message.Content.ReadAsStringAsync()), UpdatedAt = timestampNow, StartedAt = timestampNow }; } pollingUrlAndRetryAfter = new Tuple <Uri, RetryConditionHeaderValue>(message.Headers.Location, message.Headers.RetryAfter); } Uri pollingUrl = pollingUrlAndRetryAfter.Item1; var retryAfter = pollingUrlAndRetryAfter.Item2; try { ScaleOutServerDatabaseSyncResult result = await this.PollSyncStatusWithRetryAsync( databaseName, pollingUrl, retryAfter.Delta ?? DefaultPollingInterval); syncResult = ScaleOutServerDatabaseSyncDetails.FromResult(result, correlationId.ToString()); } catch (Exception e) { var timestampNow = DateTime.Now; // Append exception message to sync details and return syncResult = new ScaleOutServerDatabaseSyncDetails { CorrelationId = correlationId.ToString(), Database = databaseName, SyncState = DatabaseSyncState.Invalid, Details = Resources.SyncASPollStatusFailureMessage.FormatInvariant( ServerName, string.Empty, timestampNow.ToString(CultureInfo.InvariantCulture), string.Format(e.StackTrace)), UpdatedAt = timestampNow, StartedAt = timestampNow }; } return syncResult; })); }