public async Task ManagedHsmRecoverDeletedVault() { Location = "westus"; var parameters = new ManagedHsmData(Location) { Sku = new ManagedHsmSku(ManagedHsmSkuFamily.B, ManagedHsmSkuName.StandardB1), Properties = ManagedHsmProperties }; parameters.Tags.InitializeFrom(Tags); var managedHsm = await ManagedHsmContainer.CreateOrUpdateAsync(VaultName, parameters).ConfigureAwait(false); // Delete await managedHsm.Value.DeleteAsync(); // Get deleted vault Assert.ThrowsAsync <RequestFailedException>(async() => { await ManagedHsmContainer.GetAsync(VaultName); }); parameters.Properties.CreateMode = CreateMode.Recover; // Recover in recover mode var recoveredVault2 = await ManagedHsmContainer.CreateOrUpdateAsync(VaultName, parameters).ConfigureAwait(false); Assert.True(recoveredVault2.Value.Data.IsEqual(managedHsm.Value.Data)); // Get recovered vault var getResult = await ManagedHsmContainer.GetAsync(VaultName); // Delete await getResult.Value.DeleteAsync(); }
public async Task ManagedHsmListKeys() { List <string> resourceIds = new List <string>(); List <ManagedHsm> vaultList = new List <ManagedHsm>(); Location = "westus"; string vaultName = Recording.GenerateAssetName("sdktestvault"); var parameters = new ManagedHsmData(Location) { Sku = new ManagedHsmSku(ManagedHsmSkuFamily.B, ManagedHsmSkuName.StandardB1), Properties = ManagedHsmProperties }; parameters.Tags.InitializeFrom(Tags); var managedHsm = await ManagedHsmContainer.CreateOrUpdateAsync(vaultName, parameters).ConfigureAwait(false); Assert.NotNull(managedHsm.Value); Assert.NotNull(managedHsm.Value.Id); resourceIds.Add(managedHsm.Value.Id); vaultList.Add(managedHsm.Value); var vaults = ManagedHsmContainer.GetAllAsync(); await foreach (var v in vaults) { Assert.True(resourceIds.Remove(v.Id)); } Assert.True(resourceIds.Count == 0); // Delete foreach (var item in vaultList) { await item.DeleteAsync(); // Purge need to use loaction parameter. Update them later. //await item.PurgeDeletedAsync(); } }
public async Task ManagedHsmCreateUpdateDelete() { Location = "southcentralus"; var parameters = new ManagedHsmData(Location) { Sku = new ManagedHsmSku(ManagedHsmSkuFamily.B, ManagedHsmSkuName.StandardB1), Properties = ManagedHsmProperties }; parameters.Tags.InitializeFrom(Tags); var managedHsm = await ManagedHsmContainer.CreateOrUpdateAsync(VaultName, parameters).ConfigureAwait(false); ValidateVault(managedHsm.Value.Data, VaultName, ResGroupName, TestEnvironment.SubscriptionId, TenantIdGuid, Location, ManagedHsmSkuFamily.B, ManagedHsmSkuName.StandardB1, CreateMode.Default, false, true, new List <string> { ObjectId }, ManagedHsmProperties.NetworkAcls, PublicNetworkAccess.Disabled, new DateTimeOffset(2008, 5, 1, 8, 6, 32, new TimeSpan(1, 0, 0)), 10, Tags); ManagedHsmProperties.PublicNetworkAccess = PublicNetworkAccess.Enabled; ManagedHsmProperties.NetworkAcls.DefaultAction = "Allow"; parameters = new ManagedHsmData(Location) { Sku = new ManagedHsmSku(ManagedHsmSkuFamily.B, ManagedHsmSkuName.StandardB1), Properties = ManagedHsmProperties }; parameters.Tags.InitializeFrom(Tags); ManagedHsm updateManagedHsm = null; if (Mode == RecordedTestMode.Record) { for (int i = 0; i < 10; i++) { try { updateManagedHsm = (await ManagedHsmContainer.CreateOrUpdateAsync(VaultName, parameters).ConfigureAwait(false)).Value; break; } catch (Exception) { Thread.Sleep(120000); } } } else { for (int i = 0; i < 10; i++) { try { updateManagedHsm = (await ManagedHsmContainer.CreateOrUpdateAsync(VaultName, parameters).ConfigureAwait(false)).Value; break; } catch (Exception) { } } } ValidateVault(updateManagedHsm.Data, VaultName, ResGroupName, TestEnvironment.SubscriptionId, TenantIdGuid, Location, ManagedHsmSkuFamily.B, ManagedHsmSkuName.StandardB1, CreateMode.Default, false, true, new List <string> { ObjectId }, ManagedHsmProperties.NetworkAcls, PublicNetworkAccess.Enabled, new DateTimeOffset(2008, 5, 1, 8, 6, 32, new TimeSpan(1, 0, 0)), 10, Tags); var retrievedVault = await ManagedHsmContainer.GetAsync(VaultName); ValidateVault(retrievedVault.Value.Data, VaultName, ResGroupName, TestEnvironment.SubscriptionId, TenantIdGuid, Location, ManagedHsmSkuFamily.B, ManagedHsmSkuName.StandardB1, CreateMode.Default, false, true, new List <string> { ObjectId }, ManagedHsmProperties.NetworkAcls, PublicNetworkAccess.Enabled, new DateTimeOffset(2008, 5, 1, 8, 6, 32, new TimeSpan(1, 0, 0)), 10, Tags); // Delete await retrievedVault.Value.DeleteAsync(); //Purge need to use loaction parameter. Update them later. //await retrievedVault.Value.PurgeDeletedAsync(); Assert.ThrowsAsync <RequestFailedException>(async() => { await ManagedHsmContainer.GetAsync(VaultName); }); }