public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(ParameterSetNames.ByFactoryObject, StringComparison.OrdinalIgnoreCase))
            {
                Name = InputObject.DataFactoryName;
                ResourceGroupName = InputObject.ResourceGroupName;
            }
            else if (ParameterSetName.Equals(ParameterSetNames.ByResourceId, StringComparison.OrdinalIgnoreCase))
            {
                var parsedResourceId = new ResourceIdentifier(ResourceId);
                Name = parsedResourceId.ResourceName;
                ResourceGroupName = parsedResourceId.ResourceGroupName;
            }

            string factoryIdentityType = FactoryIdentityType.SystemAssigned;

            if (!string.IsNullOrWhiteSpace(this.IdentityType))
            {
                factoryIdentityType = this.IdentityType;
            }

            if (this.UserAssignedIdentity != null && this.UserAssignedIdentity.Count > 0)
            {
                if (!factoryIdentityType.ToLower().Contains(FactoryIdentityType.UserAssigned.ToLower()))
                {
                    factoryIdentityType = FactoryIdentityType.SystemAssignedUserAssigned;
                }
            }
            FactoryIdentity factoryIdentity = new FactoryIdentity(factoryIdentityType, userAssignedIdentities: this.UserAssignedIdentity);

            EncryptionConfiguration encryption = null;

            if (!string.IsNullOrWhiteSpace(this.EncryptionVaultBaseUrl) && !string.IsNullOrWhiteSpace(this.EncryptionKeyName))
            {
                CMKIdentityDefinition cmkIdentity = null;
                if (!string.IsNullOrWhiteSpace(this.EncryptionUserAssignedIdentity))
                {
                    cmkIdentity = new CMKIdentityDefinition(this.EncryptionUserAssignedIdentity);
                }
                encryption = new EncryptionConfiguration(this.EncryptionKeyName, this.EncryptionVaultBaseUrl, this.EncryptionKeyVersion, cmkIdentity);
            }

            var parameters = new UpdatePSDataFactoryParameters()
            {
                ResourceGroupName       = ResourceGroupName,
                DataFactoryName         = Name,
                EncryptionConfiguration = encryption,
                FactoryIdentity         = factoryIdentity,
                Tags = Tag
            };

            if (ShouldProcess(Name))
            {
                WriteObject(DataFactoryClient.UpdatePSDataFactory(parameters));
            }
        }
Example #2
0
        public override void ExecuteCmdlet()
        {
            this.ValidateParameters();

            FactoryRepoConfiguration repoConfiguration = null;

            if (!string.IsNullOrWhiteSpace(this.ProjectName) || !string.IsNullOrWhiteSpace(this.TenantId))
            {
                var factoryVSTSConfiguration = new FactoryVSTSConfiguration();
                factoryVSTSConfiguration.ProjectName = this.ProjectName;
                factoryVSTSConfiguration.TenantId    = this.TenantId;

                repoConfiguration = factoryVSTSConfiguration;
            }
            else if (!string.IsNullOrWhiteSpace(this.HostName))
            {
                var factoryGitHubConfiguration = new FactoryGitHubConfiguration();
                factoryGitHubConfiguration.HostName = this.HostName;

                repoConfiguration = factoryGitHubConfiguration;
            }

            if (repoConfiguration != null)
            {
                repoConfiguration.CollaborationBranch = this.CollaborationBranch;
                repoConfiguration.AccountName         = this.AccountName;
                repoConfiguration.LastCommitId        = this.LastCommitId;
                repoConfiguration.RootFolder          = this.RootFolder;
                repoConfiguration.RepositoryName      = this.RepositoryName;
            }

            string factoryIdentityType = FactoryIdentityType.SystemAssigned;

            if (!string.IsNullOrWhiteSpace(this.IdentityType))
            {
                factoryIdentityType = this.IdentityType;
            }

            if (this.UserAssignedIdentity != null && this.UserAssignedIdentity.Count > 0)
            {
                if (!factoryIdentityType.ToLower().Contains(FactoryIdentityType.UserAssigned.ToLower()))
                {
                    factoryIdentityType = FactoryIdentityType.SystemAssignedUserAssigned;
                }
            }
            FactoryIdentity factoryIdentity = new FactoryIdentity(factoryIdentityType, userAssignedIdentities: this.UserAssignedIdentity);

            EncryptionConfiguration encryption = null;

            if (!string.IsNullOrWhiteSpace(this.EncryptionVaultBaseUrl) && !string.IsNullOrWhiteSpace(this.EncryptionKeyName))
            {
                CMKIdentityDefinition cmkIdentity = null;
                if (!string.IsNullOrWhiteSpace(this.EncryptionUserAssignedIdentity))
                {
                    cmkIdentity = new CMKIdentityDefinition(this.EncryptionUserAssignedIdentity);
                }
                encryption = new EncryptionConfiguration(this.EncryptionKeyName, this.EncryptionVaultBaseUrl, this.EncryptionKeyVersion, cmkIdentity);
            }

            string publicNetworkAccess = Management.DataFactory.Models.PublicNetworkAccess.Enabled;

            if (!string.IsNullOrWhiteSpace(this.PublicNetworkAccess))
            {
                publicNetworkAccess = this.PublicNetworkAccess;
            }

            var parameters = new CreatePSDataFactoryParameters()
            {
                ResourceGroupName       = ResourceGroupName,
                DataFactoryName         = Name,
                Location                = Location,
                PublicNetworkAccess     = publicNetworkAccess,
                EncryptionConfiguration = encryption,
                FactoryIdentity         = factoryIdentity,
                Tags              = Tag,
                Force             = Force.IsPresent,
                RepoConfiguration = repoConfiguration,
                ConfirmAction     = ConfirmAction,
                GlobalParameters  = GlobalParameterDefinition
            };

            WriteObject(DataFactoryClient.CreatePSDataFactory(parameters));
        }