///GENMHASH:861A97732A551A94F695C3B49DFAB96C:E348102753EC23A2170268E43AF0844B public override DiskEncryptionSettings StorageProfileEncryptionSettings() { KeyVaultKeyReference keyEncryptionKey = null; if (settings.KeyEncryptionKeyURL() != null) { keyEncryptionKey = new KeyVaultKeyReference() { KeyUrl = settings.KeyEncryptionKeyURL() }; if (settings.KeyEncryptionKeyVaultId() != null) { keyEncryptionKey.SourceVault = new ResourceManager.Fluent.SubResource() { Id = settings.KeyEncryptionKeyVaultId() }; } } DiskEncryptionSettings diskEncryptionSettings = new DiskEncryptionSettings() { Enabled = true, KeyEncryptionKey = keyEncryptionKey, DiskEncryptionKey = new KeyVaultSecretReference() { SourceVault = new ResourceManager.Fluent.SubResource() { Id = settings.KeyVaultId() } } }; return(diskEncryptionSettings); }
/// <summary> /// Executes the integration account certificate create command. /// </summary> public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (this.Metadata != null) { this.Metadata = CmdletHelper.ConvertToMetadataJObject(this.Metadata); } string certificate = null; var integrationAccount = IntegrationAccountClient.GetIntegrationAccount(this.ResourceGroupName, this.Name); if (!string.IsNullOrEmpty(this.PublicCertificateFilePath)) { var certificateFilePath = this.TryResolvePath(this.PublicCertificateFilePath); if (!string.IsNullOrEmpty(certificateFilePath) && CmdletHelper.FileExists(certificateFilePath)) { var cert = new X509Certificate2(certificateFilePath); certificate = Convert.ToBase64String(cert.RawData); } } KeyVaultKeyReference keyref = null; if (!string.IsNullOrEmpty(this.KeyName) && !string.IsNullOrEmpty(this.KeyVersion) && !string.IsNullOrEmpty(this.KeyVaultId)) { keyref = new KeyVaultKeyReference { KeyName = this.KeyName, KeyVersion = this.KeyVersion, KeyVault = new KeyVaultKeyReferenceKeyVault() { Id = this.KeyVaultId } }; } this.WriteObject( IntegrationAccountClient.CreateIntegrationAccountCertificate(this.ResourceGroupName, integrationAccount.Name, this.CertificateName, new IntegrationAccountCertificate { Key = keyref, Metadata = this.Metadata, PublicCertificate = certificate } ), true); }
internal DiskEncryptionSettings(KeyVaultSecretReference diskEncryptionKey, KeyVaultKeyReference keyEncryptionKey, bool?enabled) { DiskEncryptionKey = diskEncryptionKey; KeyEncryptionKey = keyEncryptionKey; Enabled = enabled; }
/// <summary> /// Create cache. /// </summary> /// <param name="name">Name of the cache.</param> /// <param name="sku">Name of the SKU.</param> /// <param name="cacheSize">Size of cache.</param> /// <param name="identity">Cache identity type.</param> /// <param name="keyVaultResourceId">Describes a resource Id to source Key vault.</param> /// <param name="encryptionKeyURL">The URL referencing a key encryption key in key vault.</param> /// <param name="skipGet">Skip get cache before creating it.</param> /// <returns>Cache object.</returns> public Cache Create(string name, string sku, int cacheSize, CacheIdentity identity, KeyVaultKeyReferenceSourceVault keyVaultResourceId = null, string encryptionKeyURL = null, bool skipGet = false) { Cache cache; CacheEncryptionSettings cacheEncryptionSettings; KeyVaultKeyReference keyVaultKeyReference; if (!skipGet) { try { cache = this.Get(name); } catch (CloudErrorException ex) { if (ex.Body.Error.Code == "ResourceNotFound") { cache = null; } else { throw; } } } else { cache = null; } if (cache == null) { var cacheSku = new CacheSku() { Name = sku }; var subnetUri = $"/subscriptions/{this.subscriptionId}/resourcegroups/{this.resourceGroup.Name}/providers/Microsoft.Network/virtualNetworks/{this.virtualNetwork.Name}/subnets/{this.subNet.Name}"; if (encryptionKeyURL is null || keyVaultResourceId is null) { keyVaultKeyReference = new KeyVaultKeyReference() { }; cacheEncryptionSettings = new CacheEncryptionSettings() { }; } else { keyVaultKeyReference = new KeyVaultKeyReference() { KeyUrl = encryptionKeyURL, SourceVault = keyVaultResourceId, }; cacheEncryptionSettings = new CacheEncryptionSettings() { KeyEncryptionKey = keyVaultKeyReference, }; } var cacheParameters = new Cache() { CacheSizeGB = cacheSize, Location = this.resourceGroup.Location, Sku = cacheSku, Subnet = subnetUri, Identity = identity, EncryptionSettings = cacheEncryptionSettings, }; cache = this.StoragecacheManagementClient.Caches.CreateOrUpdate(this.resourceGroup.Name, name, cacheParameters); }