public override void ExecuteCmdlet() { this.ByResourceId(); this.ByIntegrationRuntimeObject(); // Set HttpClient timeout to 3 minutes. This is workaround for AMS return "Internal Server Error" issue // which will make the client call timeout due to retry. try { DataFactoryClient.DataFactoryManagementClient.HttpClient.Timeout = TimeSpan.FromMinutes(3); } catch (Exception) { // In case running the senario tests, HttpClient will complain it is not the first time running, // the property can't be changed. Just suppress the excetion. } var integrationRuntime = this.DataFactoryClient.GetIntegrationRuntimeAsync( ResourceGroupName, DataFactoryName, Name).ConfigureAwait(true).GetAwaiter().GetResult(); Action startIntegrationRuntime = () => { PSManagedIntegrationRuntimeStatus response = null; var cancellationTokenSource = new CancellationTokenSource(); var task = Task.Run(() => { response = this.DataFactoryClient.StartIntegrationRuntimeAsync( ResourceGroupName, DataFactoryName, Name, integrationRuntime.IntegrationRuntime).ConfigureAwait(true).GetAwaiter().GetResult(); }, cancellationTokenSource.Token); UpdateProgress(task, new ProgressRecord(1, "Start", "Starting Progress")); if (response != null) { WriteObject(response); } }; ConfirmAction( Force.IsPresent, string.Format( CultureInfo.InvariantCulture, Resources.IntegrationRuntimeExists, Name, DataFactoryName), string.Format( CultureInfo.InvariantCulture, Resources.IntegrationRuntimeStarting, Name, DataFactoryName), Name, startIntegrationRuntime); }
public override void ExecuteCmdlet() { if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.WorkspaceName = resourceIdentifier.ParentResource; this.WorkspaceName = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1); this.Name = resourceIdentifier.ResourceName; } if (this.IsParameterBound(c => c.WorkspaceObject)) { this.ResourceGroupName = new ResourceIdentifier(this.WorkspaceObject.Id).ResourceGroupName; this.WorkspaceName = this.WorkspaceObject.Name; } if (this.IsParameterBound(c => c.InputObject)) { this.ResourceGroupName = InputObject.ResourceGroupName; this.WorkspaceName = InputObject.WorkspaceName; this.Name = InputObject.Name; } IntegrationRuntimeResource resource = SynapseAnalyticsClient.GetIntegrationRuntimeAsync( ResourceGroupName, WorkspaceName, Name).ConfigureAwait(true).GetAwaiter().GetResult().IntegrationRuntime; Action startIntegrationRuntime = () => { PSManagedIntegrationRuntimeStatus response = null; var cancellationTokenSource = new CancellationTokenSource(); var task = Task.Run(() => { response = this.SynapseAnalyticsClient.StartIntegrationRuntimeAsync( ResourceGroupName, WorkspaceName, Name, resource).ConfigureAwait(true).GetAwaiter().GetResult(); }, cancellationTokenSource.Token); UpdateProgress(task, new ProgressRecord(1, "Start", "Starting Progress")); if (response != null) { WriteObject(response); } }; ConfirmAction( Force.IsPresent, string.Format( CultureInfo.InvariantCulture, Resources.IntegrationRuntimeExists, Name, WorkspaceName), string.Format( CultureInfo.InvariantCulture, Resources.StartingIntegrationRuntime, Name, WorkspaceName), Name, startIntegrationRuntime); }