public override void ExecuteCmdlet()
        {
            this.ByResourceId();
            this.ByIntegrationRuntimeObject();

            if (string.IsNullOrWhiteSpace(KeyName))
            {
                throw new PSArgumentNullException("KeyName");
            }

            PSIntegrationRuntimeKeys authKey           = null;
            Action regenerateIntegrationRuntimeAuthKey = () =>
            {
                authKey = DataFactoryClient.RegenerateIntegrationRuntimeAuthKeyAsync(
                    ResourceGroupName,
                    DataFactoryName,
                    Name,
                    KeyName).ConfigureAwait(true).GetAwaiter().GetResult();
            };

            ConfirmAction(
                Force.IsPresent,
                // prompt only if the integration runtime exists
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.ContinueRegenerateAuthKey,
                    KeyName,
                    Name),
                // Process message,
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.RegenerateAuthKey,
                    KeyName,
                    Name),
                // Target
                Name,
                regenerateIntegrationRuntimeAuthKey,
                () => DataFactoryClient.CheckIntegrationRuntimeExistsAsync(
                    ResourceGroupName,
                    DataFactoryName,
                    Name).ConfigureAwait(true).GetAwaiter().GetResult());

            WriteObject(authKey);
        }
Exemplo n.º 2
0
        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.IsNullOrWhiteSpace(KeyName))
            {
                throw new PSArgumentNullException("KeyName");
            }

            PSIntegrationRuntimeKeys authKey           = null;
            Action regenerateIntegrationRuntimeAuthKey = () =>
            {
                authKey = SynapseAnalyticsClient.RegenerateIntegrationRuntimeAuthKeyAsync(
                    ResourceGroupName,
                    WorkspaceName,
                    Name,
                    KeyName).ConfigureAwait(true).GetAwaiter().GetResult();
            };

            ConfirmAction(
                Force.IsPresent,
                // prompt only if the integration runtime exists
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.ContinueRegenerateAuthKey,
                    KeyName,
                    Name),
                // Process message,
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.RegenerateAuthKey,
                    KeyName,
                    Name),
                // Target
                Name,
                regenerateIntegrationRuntimeAuthKey,
                () => SynapseAnalyticsClient.CheckIntegrationRuntimeExistsAsync(
                    ResourceGroupName,
                    WorkspaceName,
                    Name).ConfigureAwait(true).GetAwaiter().GetResult());

            WriteObject(authKey);
        }