コード例 #1
0
 private void VerifyKeyVaultProperties(KeyVaultProperties keyVaultProperties, string keyName, string keyVersion, string keyVaultUri)
 {
     Assert.NotNull(keyVaultProperties);
     Assert.Equal(keyVaultProperties.KeyName, keyName);
     Assert.Equal(keyVaultProperties.KeyVersion, keyVersion);
     Assert.Equal(keyVaultProperties.KeyVaultUri, keyVaultUri);
 }
コード例 #2
0
 internal Encryption(EncryptionServices services, KeySource keySource, bool?requireInfrastructureEncryption, KeyVaultProperties keyVaultProperties)
 {
     Services  = services;
     KeySource = keySource;
     RequireInfrastructureEncryption = requireInfrastructureEncryption;
     KeyVaultProperties = keyVaultProperties;
 }
コード例 #3
0
 internal Encryption(EncryptionServices services, KeySource?keySource, bool?requireInfrastructureEncryption, KeyVaultProperties keyVaultProperties, EncryptionIdentity encryptionIdentity)
 {
     Services  = services;
     KeySource = keySource;
     RequireInfrastructureEncryption = requireInfrastructureEncryption;
     KeyVaultProperties = keyVaultProperties;
     EncryptionIdentity = encryptionIdentity;
 }
コード例 #4
0
        private void Initialize()
        {
            clusterForEventGridTestResourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupForTest}/providers/Microsoft.Kusto/Clusters/{clusterForEventGridTest}";
            eventHubNamespaceResourceId       = $"/subscriptions/{subscriptionId}/resourceGroups/test-clients-rg/providers/Microsoft.EventHub/namespaces/testclientsns22";
            eventHubResourceId = $"/subscriptions/{subscriptionId}/resourceGroups/test-clients-rg/providers/Microsoft.EventHub/namespaces/testclientsns22/eventhubs/testclientseh";
            storageAccountForEventGridResourceId = $"/subscriptions/{subscriptionId}/resourceGroups/test-clients-rg/providers/Microsoft.Storage/storageAccounts/testclients";
            iotHubResourceId       = $"/subscriptions/{subscriptionId}/resourceGroups/test-clients-rg/providers/Microsoft.Devices/IotHubs/test-clients-iot";
            privateNetworkSubnetId = $"/subscriptions/{subscriptionId}/resourceGroups/test-clients-rg/providers/Microsoft.Network/virtualNetworks/test-clients-vnet/subnets/default";

            rgName = TestUtilities.GenerateName("sdktestrg");
            resourcesClient.ResourceGroups.CreateOrUpdate(rgName, new ResourceGroup {
                Location = location
            });

            clusterName         = TestUtilities.GenerateName("testcluster");
            followerClusterName = TestUtilities.GenerateName("testfollower");
            databaseName        = TestUtilities.GenerateName("testdatabase");
            attachedDatabaseConfigurationName = TestUtilities.GenerateName("testattacheddatabaseconfiguration");
            eventHubConnectionName            = TestUtilities.GenerateName("eventhubConnection");
            eventGridConnectinoName           = TestUtilities.GenerateName("eventGridConnection");
            iotHubConnectionName          = TestUtilities.GenerateName("iothubConnection");
            privateEndpointConnectionName = TestUtilities.GenerateName("privateendpointname");
            managedPrivateEndpointName    = TestUtilities.GenerateName("managedprivateendpointname");

            sku1 = new AzureSku(name: "Standard_D13_v2", "Standard", capacity: 2);
            sku2 = new AzureSku(name: "Standard_D14_v2", "Standard", capacity: 2);

            trustedExternalTenants = new List <TrustedExternalTenant>(1)
            {
                new TrustedExternalTenant(this.tenantId)
            };

            hotCachePeriod1   = TimeSpan.FromDays(2);
            softDeletePeriod1 = TimeSpan.FromDays(4);

            hotCachePeriod2   = TimeSpan.FromDays(3);
            softDeletePeriod2 = TimeSpan.FromDays(6);

            cluster                 = new Cluster(sku: new AzureSku(name: "Standard_D13_v2", "Standard", 2), location: location, trustedExternalTenants: trustedExternalTenants, identity: new Identity(IdentityType.SystemAssigned));
            followerCluster         = new Cluster(sku: new AzureSku(name: "Standard_D13_v2", "Standard", 2), location: location, trustedExternalTenants: trustedExternalTenants);
            database                = new ReadWriteDatabase(location: location, softDeletePeriod: softDeletePeriod1, hotCachePeriod: hotCachePeriod1);
            eventhubConnection      = new EventHubDataConnection(eventHubResourceId, consumerGroupName, location: location);
            eventGridDataConnection = new EventGridDataConnection(storageAccountForEventGridResourceId, eventHubResourceId, consumerGroupName, tableName: tableName, dataFormat: dataFormat, location: location);
            iotHubDataConnection    = new IotHubDataConnection(iotHubResourceId, consumerGroupName, sharedAccessPolicyNameForIotHub, location: location);
            script = new Script(scriptUrl: scriptUrl, scriptUrlSasToken: scriptUrlSasToken, forceUpdateTag: forceUpdateTag, continueOnErrors: continueOnErrors);

            databasePrincipal  = GetDatabasePrincipalList(dBprincipalMail, "Admin");
            databasePrincipals = new List <DatabasePrincipal> {
                databasePrincipal
            };

            var leaderClusterResourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{rgName}/providers/Microsoft.Kusto/Clusters/{clusterName}";

            attachedDatabaseConfiguration = new AttachedDatabaseConfiguration(location: this.location, databaseName: databaseName, clusterResourceId: leaderClusterResourceId, defaultPrincipalsModificationKind: defaultPrincipalsModificationKind);
            keyVaultProperties            = new KeyVaultProperties(KeyNameForKeyVaultPropertiesTest, KeyVersionForKeyVaultPropertiesTest, KeyVaultUriForKeyVaultPropertiesTest);
        }
コード例 #5
0
 public PSKeyVaultPropertiesAttributes(KeyVaultProperties resKeyVaultProperties)
 {
     if (resKeyVaultProperties != null)
     {
         KeyName     = resKeyVaultProperties.KeyName;
         KeyVaultUri = resKeyVaultProperties.KeyVaultUri;
         KeyVersion  = resKeyVaultProperties.KeyVersion;
     }
     ;
 }
コード例 #6
0
        private void Initialize()
        {
            rgName = TestUtilities.GenerateName("sdktestrg");
            resourcesClient.ResourceGroups.CreateOrUpdate(rgName, new ResourceGroup {
                Location = this.location
            });

            clusterName         = TestUtilities.GenerateName("testcluster");
            followerClusterName = TestUtilities.GenerateName("testfollower");
            databaseName        = TestUtilities.GenerateName("testdatabase");
            attachedDatabaseConfigurationName = TestUtilities.GenerateName("testattacheddatabaseconfiguration");
            eventHubConnectionName            = TestUtilities.GenerateName("eventhubConnection");
            eventGridConnectinoName           = TestUtilities.GenerateName("eventGridConnection");
            iotHubConnectionName = TestUtilities.GenerateName("iothubConnection");
            scriptName           = "dor";


            sku1 = new AzureSku(name: "Standard_D13_v2", "Standard", capacity: 2);
            sku2 = new AzureSku(name: "Standard_D14_v2", "Standard", capacity: 2);

            trustedExternalTenants = new List <TrustedExternalTenant>(1)
            {
                new TrustedExternalTenant(this.tenantId)
            };

            hotCachePeriod1   = TimeSpan.FromDays(2);
            softDeletePeriod1 = TimeSpan.FromDays(4);

            hotCachePeriod2   = TimeSpan.FromDays(3);
            softDeletePeriod2 = TimeSpan.FromDays(6);
            dataFormat        = "CSV";

            defaultPrincipalsModificationKind = "Replace";

            cluster                 = new Cluster(sku: new AzureSku(name: "Standard_D13_v2", "Standard", 2), location: this.location, trustedExternalTenants: trustedExternalTenants);
            followerCluster         = new Cluster(sku: new AzureSku(name: "Standard_D13_v2", "Standard", 2), location: this.location, trustedExternalTenants: trustedExternalTenants);
            database                = new ReadWriteDatabase(location: this.location, softDeletePeriod: softDeletePeriod1, hotCachePeriod: hotCachePeriod1);
            eventhubConnection      = new EventHubDataConnection(eventHubResourceId, consumerGroupName, location: this.location);
            eventGridDataConnection = new EventGridDataConnection(storageAccountForEventGridResourceId, eventHubResourceId, consumerGroupName, tableName: tableName, dataFormat: dataFormat, location: location);
            iotHubDataConnection    = new IotHubDataConnection(iotHubResourceId, consumerGroupName, sharedAccessPolicyNameForIotHub, location: location);
            script = new Script(scriptUrl, scriptUrlSasToken, forceUpdateTag: forceUpdateTag, continueOnErrors: continueOnErrors);

            databasePrincipal  = GetDatabasePrincipalList(dBprincipalMail, "Admin");
            databasePrincipals = new List <DatabasePrincipal> {
                databasePrincipal
            };

            var leaderClusterResourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{rgName}/providers/Microsoft.Kusto/Clusters/{clusterName}";

            attachedDatabaseConfiguration = new AttachedDatabaseConfiguration(location: this.location, databaseName: databaseName, clusterResourceId: leaderClusterResourceId, defaultPrincipalsModificationKind: defaultPrincipalsModificationKind);

            keyVaultProperties = new KeyVaultProperties(KeyNameForKeyVaultPropertiesTest, KeyVaultUriForKeyVaultPropertiesTest, KeyVersionForKeyVaultPropertiesTest);
        }
コード例 #7
0
ファイル: PSCluster.cs プロジェクト: viparek/azure-powershell
 public Cluster getCluster()
 {
     return(new Cluster(
                name: Name,
                location: Location,
                tags: getTags(),
                identity: Identity?.getIdentity(),
                sku: Sku?.getClusterSku(),
                isDoubleEncryptionEnabled: IsDoubleEncryptionEnabled,
                isAvailabilityZonesEnabled: IsAvailabilityZonesEnabled,
                billingType: BillingType,
                keyVaultProperties: KeyVaultProperties?.GetKeyVaultProperties()
                ));
 }
コード例 #8
0
        public override void ExecuteCmdlet()
        {
            try
            {
                UserAssignedIdentityProperties uaip = null;

                if (UserAssignedIdentity != null)
                {
                    uaip = new UserAssignedIdentityProperties(UserAssignedIdentity);
                }

                KeyVaultProperties kvp = new KeyVaultProperties(keyName: KeyName, keyVaultUri: KeyVaultUri, keyVersion: KeyVersion, identity: uaip);

                PSEncryptionConfigAttributes keyvaultproperty = new PSEncryptionConfigAttributes(kvp);

                WriteObject(keyvaultproperty);
            }
            catch (Exception ex)
            {
                WriteObject(new ErrorRecord(ex, ex.Message, ErrorCategory.OpenError, ex));
            }
        }
コード例 #9
0
        public PSEncryptionConfigAttributes(KeyVaultProperties keyVaultProperties)
        {
            if (keyVaultProperties != null)
            {
                KeyName = keyVaultProperties?.KeyName;

                KeyVaultUri = keyVaultProperties?.KeyVaultUri;

                KeyVersion = keyVaultProperties?.KeyVersion;

                if (KeyVersion == null)
                {
                    KeyVersion = "";
                }

                if (KeyVaultUri != null)
                {
                    KeyVaultUri = KeyVaultUri.EndsWith("/") ? KeyVaultUri.Substring(0, KeyVaultUri.Length - 1) : KeyVaultUri;
                }

                UserAssignedIdentity = keyVaultProperties?.Identity?.UserAssignedIdentity;
            }
        }
コード例 #10
0
 internal Encryption(EncryptionServices services, KeySource keySource, KeyVaultProperties keyVaultProperties)
 {
     Services           = services;
     KeySource          = keySource;
     KeyVaultProperties = keyVaultProperties;
 }
コード例 #11
0
        public PSNamespaceAttributes BeginCreateNamespace(string resourceGroupName, string namespaceName, string location, string skuName, int?skuCapacity, Dictionary <string, string> tags, bool isAutoInflateEnabled, int?maximumThroughputUnits, bool isKafkaEnabled, string clusterARMId, bool isZoneRedundant, bool isDisableLocalAuth, bool isIdentity
                                                          , string identityType, string[] identityId, PSEncryptionConfigAttributes[] encryptionConfigs)
        {
            EHNamespace parameter = new EHNamespace();

            parameter.Location = location;

            if (tags != null)
            {
                parameter.Tags = new Dictionary <string, string>(tags);
            }

            if (skuName != null)
            {
                parameter.Sku = new Sku
                {
                    Name = skuName,
                    Tier = skuName
                };
            }

            if (clusterARMId != null)
            {
                parameter.ClusterArmId = clusterARMId;
            }

            if (skuCapacity.HasValue)
            {
                parameter.Sku.Capacity = skuCapacity;
            }

            if (isAutoInflateEnabled)
            {
                parameter.IsAutoInflateEnabled = isAutoInflateEnabled;
            }

            if (maximumThroughputUnits.HasValue)
            {
                parameter.MaximumThroughputUnits = maximumThroughputUnits;
            }

            if (isKafkaEnabled)
            {
                parameter.KafkaEnabled = isKafkaEnabled;
            }

            if (isZoneRedundant)
            {
                parameter.ZoneRedundant = isZoneRedundant;
            }

            if (isDisableLocalAuth)
            {
                parameter.DisableLocalAuth = isDisableLocalAuth;
            }

            if (isIdentity)
            {
                parameter.Identity = new Identity()
                {
                    Type = ManagedServiceIdentityType.SystemAssigned
                }
            }
            ;

            if (identityType != null)
            {
                parameter.Identity      = new Identity();
                parameter.Identity.Type = FindIdentity(identityType);
            }

            if (identityId != null)
            {
                Dictionary <string, UserAssignedIdentity> UserAssignedIdentities = new Dictionary <string, UserAssignedIdentity>();

                UserAssignedIdentities = identityId.Where(id => id != null).ToDictionary(id => id, id => new UserAssignedIdentity());

                if (parameter.Identity == null)
                {
                    parameter.Identity = new Identity()
                    {
                        UserAssignedIdentities = UserAssignedIdentities
                    };
                }
                else
                {
                    parameter.Identity.UserAssignedIdentities = UserAssignedIdentities;
                }
                if (parameter.Identity.Type == ManagedServiceIdentityType.None || parameter.Identity.Type == ManagedServiceIdentityType.SystemAssigned)
                {
                    throw new Exception("Please change -IdentityType to 'UserAssigned' or 'SystemAssigned, UserAssigned' if you want to add User Assigned Identities");
                }
            }

            if (encryptionConfigs != null)
            {
                if (parameter.Encryption == null)
                {
                    parameter.Encryption = new Encryption()
                    {
                        KeySource = KeySource.MicrosoftKeyVault
                    };
                }

                parameter.Encryption.KeyVaultProperties = new List <KeyVaultProperties>();

                parameter.Encryption.KeyVaultProperties = encryptionConfigs.Where(x => x != null)
                                                          .Select(x => {
                    KeyVaultProperties kvp = new KeyVaultProperties();

                    if (x.KeyName == null || x.KeyVaultUri == null)
                    {
                        throw new Exception("KeyName and KeyVaultUri cannot be null");
                    }

                    kvp.KeyName = x.KeyName;

                    kvp.KeyVaultUri = x.KeyVaultUri;

                    kvp.KeyVersion = x?.KeyVersion;

                    if (x.UserAssignedIdentity != null)
                    {
                        kvp.Identity = new UserAssignedIdentityProperties(x.UserAssignedIdentity);
                    }

                    return(kvp);
                })
                                                          .ToList();
            }

            var response = Client.Namespaces.CreateOrUpdate(resourceGroupName, namespaceName, parameter);

            return(new PSNamespaceAttributes(response));
        }
コード例 #12
0
        // Update Namespace                                                     (ResourceGroupName, Name, Location, SkuName, SkuCapacity, tagDictionary, EnableAutoInflate.IsPresent, MaximumThroughputUnits, EnableKafka.IsPresent, ZoneRedundant.IsPresent, Identity.IsPresent, IdentityUserDefined, KeySource, KeyProperties));
        public PSNamespaceAttributes BeginUpdateNamespace(string resourceGroupName,
                                                          string namespaceName,
                                                          string location,
                                                          string skuName,
                                                          int?skuCapacity,
                                                          Dictionary <string, string> tags,
                                                          bool isAutoInflateEnabled,
                                                          int?maximumThroughputUnits,
                                                          bool isKafkaEnabled, bool isIdentity, string identityUserDefined, string keySource, List <string []> KeyProperties, bool isDisableLocalAuth,
                                                          string[] identityId, string identityType, PSEncryptionConfigAttributes[] encryptionConfigs)
        {
            EHNamespace parameter = Client.Namespaces.Get(resourceGroupName, namespaceName);

            if (parameter.Identity != null && parameter.Encryption != null && KeyProperties != null)
            {
                parameter.Encryption = new Encryption();
                parameter.Encryption.KeyVaultProperties = new List <KeyVaultProperties>();
            }

            if (location != null)
            {
                parameter.Location = location;
            }

            if (tags != null)
            {
                parameter.Tags = new Dictionary <string, string>(tags);
            }

            if (skuName != null)
            {
                parameter.Sku = new Sku
                {
                    Name = skuName,
                    Tier = skuName
                };
            }

            if (skuCapacity.HasValue)
            {
                parameter.Sku.Capacity = skuCapacity;
            }

            if (isAutoInflateEnabled)
            {
                parameter.IsAutoInflateEnabled = isAutoInflateEnabled;
            }

            if (maximumThroughputUnits.HasValue)
            {
                parameter.MaximumThroughputUnits = maximumThroughputUnits;
            }

            if (isKafkaEnabled)
            {
                parameter.KafkaEnabled = isKafkaEnabled;
            }

            if (isIdentity)
            {
                if (parameter.Identity == null)
                {
                    parameter.Identity = new Identity()
                    {
                        Type = ManagedServiceIdentityType.SystemAssigned
                    };
                }
                else
                {
                    if (parameter.Identity.Type == ManagedServiceIdentityType.None)
                    {
                        parameter.Identity = new Identity()
                        {
                            Type = ManagedServiceIdentityType.SystemAssigned
                        };
                    }
                    if (parameter.Identity.Type == ManagedServiceIdentityType.UserAssigned)
                    {
                        parameter.Identity = new Identity()
                        {
                            Type = ManagedServiceIdentityType.SystemAssignedUserAssigned
                        };
                    }
                }
            }

            if (isDisableLocalAuth)
            {
                parameter.DisableLocalAuth = isDisableLocalAuth;
            }


            //IdentityUserDefined, KeySource, KeyProperties
            if (!String.IsNullOrEmpty(identityUserDefined) && identityUserDefined.ToLower() == "none")
            {
                parameter.Identity = new Identity()
                {
                    Type = null
                };
            }

            if (!String.IsNullOrEmpty(keySource))
            {
                if (parameter.Encryption == null)
                {
                    parameter.Encryption = new Encryption()
                    {
                        KeySource = KeySource.MicrosoftKeyVault
                    };
                }
                else
                {
                    parameter.Encryption.KeySource = KeySource.MicrosoftKeyVault;
                }
            }

            if (KeyProperties != null)
            {
                parameter.Encryption.KeyVaultProperties = new List <KeyVaultProperties>();

                if (KeyProperties.Count > 2)
                {
                    if (KeyProperties[0].Length == 1)
                    {
                        KeyVaultProperties item = new KeyVaultProperties();

                        switch (KeyProperties.Count)
                        {
                        case 2:
                        {
                            item.KeyName     = KeyProperties[0].ToString();
                            item.KeyVaultUri = KeyProperties[0].ToString();
                            break;
                        }

                        case 3:
                        {
                            item.KeyName     = KeyProperties[0].GetValue(0).ToString();
                            item.KeyVaultUri = KeyProperties[1].GetValue(0).ToString();
                            item.KeyVersion  = KeyProperties[2].GetValue(0).ToString();
                            break;
                        }
                        }
                        parameter.Encryption.KeyVaultProperties.Add(item);
                    }
                    else
                    {
                        foreach (string[] item in KeyProperties)
                        {
                            KeyVaultProperties singleItem = new KeyVaultProperties();
                            switch (item.Length)
                            {
                            case 2:
                            {
                                singleItem.KeyName     = item[0];
                                singleItem.KeyVaultUri = item[1];
                                break;
                            }

                            case 3:
                            {
                                singleItem.KeyName     = item[0];
                                singleItem.KeyVaultUri = item[1];
                                singleItem.KeyVersion  = item[2];
                                break;
                            }
                            }

                            parameter.Encryption.KeyVaultProperties.Add(singleItem);
                        }
                    }
                }
            }
            if (identityType != null)
            {
                if (parameter.Identity == null)
                {
                    parameter.Identity = new Identity();
                }

                parameter.Identity.Type = FindIdentity(identityType);

                if (parameter.Identity.Type == ManagedServiceIdentityType.None || parameter.Identity.Type == ManagedServiceIdentityType.SystemAssigned)
                {
                    parameter.Identity.UserAssignedIdentities = null;
                }
            }

            if (identityId != null)
            {
                Dictionary <string, UserAssignedIdentity> UserAssignedIdentities = new Dictionary <string, UserAssignedIdentity>();

                UserAssignedIdentities = identityId.Where(id => id != null).ToDictionary(id => id, id => new UserAssignedIdentity());

                if (parameter.Identity == null)
                {
                    parameter.Identity = new Identity()
                    {
                        UserAssignedIdentities = UserAssignedIdentities
                    };
                }
                else
                {
                    parameter.Identity.UserAssignedIdentities = UserAssignedIdentities;
                }
                if (parameter.Identity.Type == ManagedServiceIdentityType.None || parameter.Identity.Type == ManagedServiceIdentityType.SystemAssigned)
                {
                    throw new Exception("Please change -IdentityType to UserAssigned or 'SystemAssigned, UserAssigned' if you want to add User Assigned Identities");
                }
            }

            if (encryptionConfigs != null)
            {
                if (parameter.Encryption == null)
                {
                    parameter.Encryption = new Encryption()
                    {
                        KeySource = KeySource.MicrosoftKeyVault
                    };
                }

                parameter.Encryption.KeyVaultProperties = new List <KeyVaultProperties>();

                parameter.Encryption.KeyVaultProperties = encryptionConfigs.Where(x => x != null)
                                                          .Select(x =>
                {
                    KeyVaultProperties kvp = new KeyVaultProperties();

                    if (x.KeyName == null || x.KeyVaultUri == null)
                    {
                        throw new Exception("KeyName and KeyVaultUri cannot be null");
                    }

                    kvp.KeyName = x.KeyName;

                    kvp.KeyVaultUri = x.KeyVaultUri;

                    kvp.KeyVersion = x?.KeyVersion;

                    if (x.UserAssignedIdentity != null)
                    {
                        kvp.Identity = new UserAssignedIdentityProperties(x.UserAssignedIdentity);
                    }

                    return(kvp);
                })
                                                          .ToList();
            }

            var response = Client.Namespaces.CreateOrUpdate(resourceGroupName, namespaceName, parameter);

            return(new PSNamespaceAttributes(response));
        }
コード例 #13
0
 public PSKeyVaultProperties(KeyVaultProperties kv)
 {
     this.KeyVaultUri = kv.KeyVaultUri;
     this.KeyName     = kv.KeyName;
     this.KeyVersion  = kv.KeyVersion;
 }
コード例 #14
0
        // Update Namespace                                                     (ResourceGroupName, Name, Location, SkuName, SkuCapacity, tagDictionary, EnableAutoInflate.IsPresent, MaximumThroughputUnits, EnableKafka.IsPresent, ZoneRedundant.IsPresent, Identity.IsPresent, IdentityUserDefined, KeySource, KeyProperties));
        public PSNamespaceAttributes BeginUpdateNamespace(string resourceGroupName, string namespaceName, string location, string skuName, int?skuCapacity, Dictionary <string, string> tags, bool isAutoInflateEnabled, int?maximumThroughputUnits, bool isKafkaEnabled, bool isIdentity, string identityUserDefined, string keySource, List <string []> KeyProperties)
        {
            EHNamespace parameter = Client.Namespaces.Get(resourceGroupName, namespaceName);

            if (parameter.Identity != null && parameter.Encryption == null)
            {
                parameter.Encryption = new Encryption();
                parameter.Encryption.KeyVaultProperties = new List <KeyVaultProperties>();
            }

            parameter.Location = location;

            if (tags != null)
            {
                parameter.Tags = new Dictionary <string, string>(tags);
            }

            if (skuName != null)
            {
                parameter.Sku = new Sku
                {
                    Name = skuName,
                    Tier = skuName
                };
            }

            if (skuCapacity.HasValue)
            {
                parameter.Sku.Capacity = skuCapacity;
            }

            if (isAutoInflateEnabled)
            {
                parameter.IsAutoInflateEnabled = isAutoInflateEnabled;
            }

            if (maximumThroughputUnits.HasValue)
            {
                parameter.MaximumThroughputUnits = maximumThroughputUnits;
            }

            if (isKafkaEnabled)
            {
                parameter.KafkaEnabled = isKafkaEnabled;
            }

            if (isIdentity)
            {
                parameter.Identity = new Identity()
                {
                    Type = IdentityType.SystemAssigned
                }
            }
            ;

            //IdentityUserDefined, KeySource, KeyProperties
            if (!String.IsNullOrEmpty(identityUserDefined) && identityUserDefined.ToLower() == "none")
            {
                parameter.Identity = new Identity()
                {
                    Type = null
                };
            }

            if (!String.IsNullOrEmpty(keySource))
            {
                if (parameter.Encryption == null)
                {
                    parameter.Encryption = new Encryption()
                    {
                        KeySource = KeySource.MicrosoftKeyVault
                    };
                }
                else
                {
                    parameter.Encryption.KeySource = KeySource.MicrosoftKeyVault;
                }
            }

            if (KeyProperties != null)
            {
                parameter.Encryption.KeyVaultProperties = new List <KeyVaultProperties>();

                if (KeyProperties.Count > 2)
                {
                    if (KeyProperties[0].Length == 1)
                    {
                        KeyVaultProperties item = new KeyVaultProperties();

                        switch (KeyProperties.Count)
                        {
                        case 2:
                        {
                            item.KeyName     = KeyProperties[0].ToString();
                            item.KeyVaultUri = KeyProperties[0].ToString();
                            break;
                        }

                        case 3:
                        {
                            item.KeyName     = KeyProperties[0].GetValue(0).ToString();
                            item.KeyVaultUri = KeyProperties[1].GetValue(0).ToString();
                            item.KeyVersion  = KeyProperties[2].GetValue(0).ToString();
                            break;
                        }
                        }
                        parameter.Encryption.KeyVaultProperties.Add(item);
                    }
                    else
                    {
                        foreach (string[] item in KeyProperties)
                        {
                            KeyVaultProperties singleItem = new KeyVaultProperties();
                            switch (item.Length)
                            {
                            case 2:
                            {
                                singleItem.KeyName     = item[0];
                                singleItem.KeyVaultUri = item[1];
                                break;
                            }

                            case 3:
                            {
                                singleItem.KeyName     = item[0];
                                singleItem.KeyVaultUri = item[1];
                                singleItem.KeyVersion  = item[2];
                                break;
                            }
                            }

                            parameter.Encryption.KeyVaultProperties.Add(singleItem);
                        }
                    }
                }
            }
            var response = Client.Namespaces.CreateOrUpdate(resourceGroupName, namespaceName, parameter);

            return(new PSNamespaceAttributes(response));
        }
コード例 #15
0
 internal EncryptionProperties(KeyVaultProperties keyVaultProperties)
 {
     KeyVaultProperties = keyVaultProperties;
 }