コード例 #1
0
        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));
            }
        }
        private void ExecuteDelete()
        {
            HttpStatusCode response = DataFactoryClient.DeleteDataFlow(ResourceGroupName, DataFactoryName, Name);

            if (response == HttpStatusCode.NoContent)
            {
                WriteWarning(string.Format(CultureInfo.InvariantCulture, Resources.DataFlowNotFound, Name, DataFactoryName));
            }

            if (this.PassThru.IsPresent)
            {
                WriteObject(true);
            }
        }