private void CaptureIntegrationRuntimes_GrantPermission() { ServiceClientTracing.IsEnabled = false; IntegrationRuntimeResource origIntegrationRuntime = client.IntegrationRuntimes.Get(secrets.ResourceGroupName, secrets.FactoryName, integrationRuntimeName); Factory LinkedFactory = client.Factories.CreateOrUpdate(secrets.ResourceGroupName, secrets.FactoryName + "-linked", new Factory { Identity = new FactoryIdentity(), Location = secrets.FactoryLocation }); Task.Delay(TimeSpan.FromSeconds(30)).Wait(); // Create role assignment authClient.RoleAssignments.Create( origIntegrationRuntime.Id, roleAssignmentName, new RoleAssignmentCreateParameters() { // Contributor RoleDefinitionId = "/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c", PrincipalId = LinkedFactory.Identity.PrincipalId.Value.ToString() }); ServiceClientTracing.IsEnabled = true; }
private void CaptureIntegrationRuntimes_UpdateLinkedIntegrationRuntime() { interceptor.CurrentExampleName = "IntegrationRuntimes_UpdateLinkedIntegrationRuntime"; IntegrationRuntimeResource resource2 = client.IntegrationRuntimes.CreateOrUpdate(secrets.ResourceGroupName, secrets.FactoryName + "-linked", integrationRuntimeName + "-linked", GetIntegrationRuntimeResource(type: "Linked", description: "A Linked integration runtime")); }
public PSLinkedIntegrationRuntime( IntegrationRuntimeResource integrationRuntime, string resourceGroupName, string workspaceName) : base(integrationRuntime, resourceGroupName, workspaceName) { }
public virtual async Task <PSManagedIntegrationRuntimeStatus> StartIntegrationRuntimeAsync( string resourceGroupName, string dataFactoryName, string integrationRuntimeName, IntegrationRuntimeResource integrationRuntime) { var response = await this.DataFactoryManagementClient.IntegrationRuntimes.BeginStartWithHttpMessagesAsync( resourceGroupName, dataFactoryName, integrationRuntimeName); try { var result = await this.DataFactoryManagementClient.GetLongRunningOperationResultAsync(response, null, default(CancellationToken)); return((PSManagedIntegrationRuntimeStatus)GenerateIntegraionRuntimeObject(integrationRuntime, result.Body, resourceGroupName, dataFactoryName)); } catch (Exception e) { throw RethrowLongingRunningException(e); } }
private PSIntegrationRuntime CreateSelfHostedIntegrationRuntime( IntegrationRuntimeResource integrationRuntime, string resourceGroupName, string dataFactoryName) { PSIntegrationRuntime psIntegrationRuntime = null; var selfHosted = integrationRuntime.Properties as SelfHostedIntegrationRuntime; if (selfHosted != null) { if (selfHosted.LinkedInfo != null) { psIntegrationRuntime = new PSLinkedIntegrationRuntime(integrationRuntime, resourceGroupName, dataFactoryName) { AuthorizationType = selfHosted.LinkedInfo is LinkedIntegrationRuntimeKey ? Constants.LinkedIntegrationRuntimeKeyAuth : Constants.LinkedIntegrationRuntimeRbacAuth }; } else { psIntegrationRuntime = new PSSelfHostedIntegrationRuntime(integrationRuntime, resourceGroupName, dataFactoryName); } } return(psIntegrationRuntime); }
public PSLinkedIntegrationRuntime( IntegrationRuntimeResource integrationRuntime, string resourceGroupName, string factoryName) : base(integrationRuntime, resourceGroupName, factoryName) { }
public void IntegrationRuntimes_Create() { RunTest("IntegrationRuntimes_Create", (example, client, responseCode) => { IntegrationRuntimeResource resource = client.IntegrationRuntimes.CreateOrUpdate(RGN(example), FN(example), IRN(example), IRR(example, client, "integrationRuntime")); CheckResponseBody(example, client, responseCode, resource); }); }
public void IntegrationRuntimes_Get() { RunTest("IntegrationRuntimes_Get", (example, client, responseCode) => { IntegrationRuntimeResource resource = client.IntegrationRuntimes.Get(RGN(example), FN(example), IRN(example)); CheckResponseBody(example, client, responseCode, resource); }); }
private PSIntegrationRuntime GenerateIntegraionRuntimeObject( IntegrationRuntimeResource integrationRuntime, IntegrationRuntimeStatusResponse status, string resourceGroupName, string dataFactoryName) { var managed = integrationRuntime.Properties as ManagedIntegrationRuntime; if (status == null) { PSIntegrationRuntime ir = (managed != null ? new PSManagedIntegrationRuntime(integrationRuntime, resourceGroupName, dataFactoryName) : CreateSelfHostedIntegrationRuntime(integrationRuntime, resourceGroupName, dataFactoryName)) ?? new PSIntegrationRuntime(integrationRuntime, resourceGroupName, dataFactoryName); return(ir); } if (managed != null) { return(new PSManagedIntegrationRuntimeStatus( integrationRuntime, (ManagedIntegrationRuntimeStatus)status.Properties, resourceGroupName, dataFactoryName)); } else { var selfHosted = integrationRuntime.Properties as SelfHostedIntegrationRuntime; if (selfHosted != null) { if (selfHosted.LinkedInfo != null) { return(new PSLinkedIntegrationRuntimeStatus( integrationRuntime, (SelfHostedIntegrationRuntimeStatus)status.Properties, resourceGroupName, dataFactoryName, DataFactoryManagementClient.DeserializationSettings, selfHosted.LinkedInfo is LinkedIntegrationRuntimeKey ? Constants.LinkedIntegrationRuntimeKeyAuth : Constants.LinkedIntegrationRuntimeRbacAuth, status.Name, status.Properties.DataFactoryName)); } return(new PSSelfHostedIntegrationRuntimeStatus( integrationRuntime, (SelfHostedIntegrationRuntimeStatus)status.Properties, resourceGroupName, dataFactoryName, DataFactoryManagementClient.DeserializationSettings)); } } // Don't support get status for legacy integraiton runtime. throw new PSInvalidOperationException("This type of integration runtime is not supported by this version powershell cmdlets."); }
public PSSelfHostedIntegrationRuntimeStatus( IntegrationRuntimeResource integrationRuntime, SelfHostedIntegrationRuntimeStatus status, string resourceGroupName, string factoryName) : base(integrationRuntime, resourceGroupName, factoryName) { _status = status; }
public PSManagedIntegrationRuntimeStatus( IntegrationRuntimeResource integrationRuntime, ManagedIntegrationRuntimeStatus status, string resourceGroupName, string workspaceName) : base(integrationRuntime, resourceGroupName, workspaceName) { _status = status; }
private void CaptureIntegrationRuntimes_Update() { interceptor.CurrentExampleName = "IntegrationRuntimes_Update"; IntegrationRuntimeResource response = client.IntegrationRuntimes.Update(secrets.ResourceGroupName, secrets.FactoryName, integrationRuntimeName, new UpdateIntegrationRuntimeRequest { AutoUpdate = IntegrationRuntimeAutoUpdate.Off, UpdateDelayOffset = SafeJsonConvert.SerializeObject(TimeSpan.FromHours(3), client.SerializationSettings) }); }
public PSSelfHostedIntegrationRuntimeStatus( IntegrationRuntimeResource integrationRuntime, SelfHostedIntegrationRuntimeStatus status, string resourceGroupName, string factoryName, JsonSerializerSettings deserializerSettings) : base(integrationRuntime, resourceGroupName, factoryName) { _status = status; _deserializerSettings = deserializerSettings; }
public PSIntegrationRuntime(IntegrationRuntimeResource integrationRuntime, string resourceGroupName, string factoryName) { if (integrationRuntime == null) { throw new ArgumentNullException(nameof(integrationRuntime)); } IntegrationRuntime = integrationRuntime; ResourceGroupName = resourceGroupName; DataFactoryName = factoryName; }
private void CaptureIntegrationRuntimes_CreateLinkedIntegrationRuntime() { interceptor.CurrentExampleName = "IntegrationRuntimes_CreateLinkedIntegrationRuntime"; ServiceClientTracing.IsEnabled = false; IntegrationRuntimeResource resource = client.IntegrationRuntimes.Get(secrets.ResourceGroupName, secrets.FactoryName, integrationRuntimeName); ServiceClientTracing.IsEnabled = true; IntegrationRuntimeResource resource2 = client.IntegrationRuntimes.CreateOrUpdate(secrets.ResourceGroupName, secrets.FactoryName + "-linked", integrationRuntimeName + "-linked", GetIntegrationRuntimeResource(type: "Linked", description: "A Linked integration runtime", resourceId: resource.Id)); }
private void CaptureIntegrationRuntimes_RevokePermission() { ServiceClientTracing.IsEnabled = false; Factory LinkedFactory = client.Factories.Get(secrets.ResourceGroupName, secrets.FactoryName + "-linked"); IntegrationRuntimeResource origIntegrationRuntime = client.IntegrationRuntimes.Get(secrets.ResourceGroupName, secrets.FactoryName, integrationRuntimeName); authClient.RoleAssignments.Delete(origIntegrationRuntime.Id, roleAssignmentName); client.Factories.Delete(secrets.ResourceGroupName, secrets.FactoryName + "-linked"); ServiceClientTracing.IsEnabled = true; }
public PSIntegrationRuntime(IntegrationRuntimeResource integrationRuntime, string resourceGroupName, string workspaceName) { if (integrationRuntime == null) { throw new ArgumentNullException(nameof(integrationRuntime)); } IntegrationRuntime = integrationRuntime; ResourceGroupName = resourceGroupName; this.WorkspaceName = workspaceName; }
public virtual async Task <IntegrationRuntimeResource> CreateOrUpdateIntegrationRuntimeAsync( string resourceGroupName, string dataFactoryName, string integrationRuntimeName, IntegrationRuntimeResource resource) { return(await this.DataFactoryManagementClient.IntegrationRuntimes.CreateOrUpdateAsync( resourceGroupName, dataFactoryName, integrationRuntimeName, resource)); }
public override void ExecuteCmdlet() { this.ByResourceId(); this.ByIntegrationRuntimeObject(); if (AutoUpdate == null && !AutoUpdateDelayOffset.HasValue) { throw new PSArgumentException("No valid parameters."); } IntegrationRuntimeResource resource = DataFactoryClient.GetIntegrationRuntimeAsync( ResourceGroupName, DataFactoryName, base.Name).ConfigureAwait(true).GetAwaiter().GetResult().IntegrationRuntime; WriteVerbose("Got integration runtime"); Action updateIntegrationRuntime = () => { var request = new UpdateIntegrationRuntimeRequest(); if (!string.IsNullOrEmpty(AutoUpdate)) { request.AutoUpdate = AutoUpdate; } WriteVerbose("Handled AutoUpdate"); if (AutoUpdateDelayOffset.HasValue) { request.UpdateDelayOffset = SafeJsonConvert.SerializeObject( AutoUpdateDelayOffset.Value, DataFactoryClient.DataFactoryManagementClient.SerializationSettings); WriteVerbose(request.UpdateDelayOffset); } WriteVerbose("Handled AutoUpdateDelayOffset"); WriteObject(DataFactoryClient.UpdateIntegrationRuntimeAsync(ResourceGroupName, DataFactoryName, Name, resource, request).ConfigureAwait(false).GetAwaiter().GetResult()); }; ConfirmAction( string.Format( CultureInfo.InvariantCulture, Resources.IntegrationRuntimeUpdating, Name, DataFactoryName), Name, updateIntegrationRuntime); }
public void IntegrationRuntimes_Update() { RunTest("IntegrationRuntimes_Update", (example, client, responseCode) => { IntegrationRuntimeResource response = client.IntegrationRuntimes.Update(RGN(example), FN(example), IRN(example), new UpdateIntegrationRuntimeRequest { AutoUpdate = IntegrationRuntimeAutoUpdate.Off, UpdateDelayOffset = SafeJsonConvert.SerializeObject(TimeSpan.FromHours(3), client.SerializationSettings) }); CheckResponseBody(example, client, responseCode, response); }); }
public async Task TestGet() { IntegrationRuntimesClient client = CreateClient(); IntegrationRuntimeListResponse integrations = await client.ListAsync(); foreach (IntegrationRuntimeResource integration in integrations.Value) { IntegrationRuntimeResource fetchedIntegration = await client.GetAsync(integration.Name); Assert.AreEqual(integration.Name, fetchedIntegration.Name); Assert.AreEqual(integration.Id, fetchedIntegration.Id); Assert.AreEqual(integration.Type, fetchedIntegration.Type); } }
private PSIntegrationRuntime GenerateIntegraionRuntimeObject( IntegrationRuntimeResource integrationRuntime, IntegrationRuntimeStatusResponse status, string resourceGroupName, string dataFactoryName) { var managed = integrationRuntime.Properties as ManagedIntegrationRuntime; if (status == null) { if (managed != null) { return(new PSManagedIntegrationRuntime(integrationRuntime, resourceGroupName, dataFactoryName)); } var selfHosted = integrationRuntime.Properties as SelfHostedIntegrationRuntime; if (selfHosted != null) { return(new PSSelfHostedIntegrationRuntime(integrationRuntime, resourceGroupName, dataFactoryName)); } // For the legacy integration runtime, we only return the most common part. return(new PSIntegrationRuntime(integrationRuntime, resourceGroupName, dataFactoryName)); } if (managed != null) { return(new PSManagedIntegrationRuntimeStatus( integrationRuntime, (ManagedIntegrationRuntimeStatus)status.Properties, resourceGroupName, dataFactoryName)); } else { var selfHosted = integrationRuntime.Properties as SelfHostedIntegrationRuntime; if (selfHosted != null) { return(new PSSelfHostedIntegrationRuntimeStatus( integrationRuntime, (SelfHostedIntegrationRuntimeStatus)status.Properties, resourceGroupName, dataFactoryName, DataFactoryManagementClient.DeserializationSettings)); } } // Don't support get status for legacy integraiton runtime. throw new PSInvalidOperationException("This type of integration runtime is not supported by this version powershell cmdlets."); }
public virtual async Task <PSManagedIntegrationRuntimeStatus> StartIntegrationRuntimeAsync( string resourceGroupName, string dataFactoryName, string integrationRuntimeName, IntegrationRuntimeResource integrationRuntime) { var response = await this.DataFactoryManagementClient.IntegrationRuntimes.StartAsync( resourceGroupName, dataFactoryName, integrationRuntimeName); return((PSManagedIntegrationRuntimeStatus)GenerateIntegraionRuntimeObject(integrationRuntime, response, resourceGroupName, dataFactoryName)); }
public PSManagedIntegrationRuntime( IntegrationRuntimeResource integrationRuntime, string resourceGroupName, string factoryName) : base(integrationRuntime, resourceGroupName, factoryName) { if (IntegrationRuntime.Properties == null) { IntegrationRuntime.Properties = new ManagedIntegrationRuntime(); } if (ManagedIntegrationRuntime == null) { throw new PSArgumentException("The resource is not a valid managed integration runtime."); } }
public PSSelfHostedIntegrationRuntime( IntegrationRuntimeResource integrationRuntime, string resourceGroupName, string workspaceName) : base(integrationRuntime, resourceGroupName, workspaceName) { if (IntegrationRuntime.Properties == null) { IntegrationRuntime.Properties = new SelfHostedIntegrationRuntime(); } if (SelfHostedIntegrationRuntime == null) { throw new PSArgumentException("The resource is not a valid self-hosted integration runtime."); } }
public PSLinkedIntegrationRuntimeStatus( IntegrationRuntimeResource integrationRuntime, SelfHostedIntegrationRuntimeStatus status, string resourceGroupName, string factoryName, JsonSerializerSettings deserializerSettings, string authType, string origIntegrationRuntimeName, string origDataFactoryName) : base(integrationRuntime, status, resourceGroupName, factoryName, deserializerSettings) { DataFactoryName = factoryName; ResourceGroupName = resourceGroupName; OriginalIntegrationRuntimeName = origIntegrationRuntimeName; OriginalDataFactoryName = origDataFactoryName; AuthorizationType = authType; }
public virtual async Task <PSIntegrationRuntime> UpdateIntegrationRuntimeAsync( string resourceGroupName, string dataFactoryName, string integrationRuntimeName, IntegrationRuntimeResource resource, UpdateIntegrationRuntimeRequest request) { var response = await this.DataFactoryManagementClient.IntegrationRuntimes.UpdateAsync( resourceGroupName, dataFactoryName, integrationRuntimeName, request); return(new PSSelfHostedIntegrationRuntime( response, resourceGroupName, dataFactoryName)); }
public virtual async Task <PSSelfHostedIntegrationRuntimeStatus> UpdateIntegrationRuntimeAsync( string resourceGroupName, string dataFactoryName, string integrationRuntimeName, IntegrationRuntimeResource resource, UpdateIntegrationRuntimeRequest request) { var response = await this.DataFactoryManagementClient.IntegrationRuntimes.UpdateAsync( resourceGroupName, dataFactoryName, integrationRuntimeName, request); var selfHostedStatus = response.Properties as SelfHostedIntegrationRuntimeStatus; return(new PSSelfHostedIntegrationRuntimeStatus( resource, selfHostedStatus, resourceGroupName, dataFactoryName, DataFactoryManagementClient.DeserializationSettings)); }
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; } if (string.Equals(Type, SynapseConstants.IntegrationRuntimeTypeManaged, StringComparison.OrdinalIgnoreCase)) { if (AuthKey != null || !string.IsNullOrWhiteSpace(SharedIntegrationRuntimeResourceId)) { throw new PSArgumentException( string.Format( CultureInfo.InvariantCulture, Resources.InvalidIntegrationRuntimeSharing), "AuthKey"); } } IntegrationRuntimeResource resource = null; var isUpdate = false; try { resource = SynapseAnalyticsClient.GetIntegrationRuntimeAsync( ResourceGroupName, WorkspaceName, Name).ConfigureAwait(true).GetAwaiter().GetResult().IntegrationRuntime; isUpdate = true; if (Type != null && (resource.Properties is ManagedIntegrationRuntime ^ Type.Equals(SynapseConstants.IntegrationRuntimeTypeManaged, StringComparison.OrdinalIgnoreCase))) { throw new PSArgumentException( string.Format( CultureInfo.InvariantCulture, Resources.IntegrationRuntimeWrongType, Name), "Type"); } if (AuthKey != null) { throw new PSArgumentException( string.Format( CultureInfo.InvariantCulture, Resources.UpdateAuthKeyNotAllowed, Name), "AuthKey"); } } catch (CloudException e) { if (e.Response.StatusCode == HttpStatusCode.NotFound) { if (Type == null) { throw new PSArgumentException( string.Format( CultureInfo.InvariantCulture, Resources.NeedIntegrationRuntimeType), "Type"); } resource = new IntegrationRuntimeResource(); if (Type.Equals(SynapseConstants.IntegrationRuntimeTypeManaged, StringComparison.OrdinalIgnoreCase)) { resource.Properties = new ManagedIntegrationRuntime(); } else { var selfHosted = new SelfHostedIntegrationRuntime(); if (AuthKey != null) { var authKey = ConvertToUnsecureString(AuthKey); selfHosted.LinkedInfo = new LinkedIntegrationRuntimeKeyAuthorization(new SecureString(authKey)); } resource.Properties = selfHosted; } } else { throw; } } if (!string.IsNullOrWhiteSpace(SharedIntegrationRuntimeResourceId)) { var selfHostedIr = resource.Properties as SelfHostedIntegrationRuntime; if (selfHostedIr != null) { selfHostedIr.LinkedInfo = new LinkedIntegrationRuntimeRbacAuthorization(SharedIntegrationRuntimeResourceId); } else { throw new PSArgumentException( string.Format( CultureInfo.InvariantCulture, Resources.InvalidIntegrationRuntimeSharing), "SharedIntegrationRuntimeResourceId"); } } if (!string.IsNullOrWhiteSpace(Description)) { resource.Properties.Description = Description; } var managedIr = resource.Properties as ManagedIntegrationRuntime; if (managedIr != null) { HandleManagedIntegrationRuntime(managedIr); } var parameters = new CreatePSIntegrationRuntimeParameters() { ResourceGroupName = ResourceGroupName, WorkspaceName = WorkspaceName, Name = Name, IsUpdate = isUpdate, IntegrationRuntimeResource = resource, Force = Force.IsPresent, ConfirmAction = base.ConfirmAction }; WriteObject(SynapseAnalyticsClient.CreateOrUpdateIntegrationRuntime(parameters)); }
private void CaptureIntegrationRuntimes_GetLinkedIntegrationRuntime() { interceptor.CurrentExampleName = "IntegrationRuntimes_GetLinkedIntegrationRuntime"; IntegrationRuntimeResource resource = client.IntegrationRuntimes.Get(secrets.ResourceGroupName, secrets.FactoryName + "-linked", integrationRuntimeName + "-linked"); }