forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RecoveryServicesBackup] Fix LRO issue (Azure#38784)
* Add LRO * Update CHANGELOG.md * Update comments * Add regression tests * Update assets.json * update --------- Co-authored-by: Chengming <[email protected]> Co-authored-by: Wei Hu <[email protected]>
- Loading branch information
1 parent
0de0102
commit 2fb0d48
Showing
10 changed files
with
125 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
### Breaking Changes | ||
|
||
### Bugs Fixed | ||
- Fix LRO in ProtectionContainers PUT operation | ||
|
||
### Other Changes | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...sourceManager.RecoveryServicesBackup/src/Generated/BackupProtectionContainerCollection.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...ResourceManager.RecoveryServicesBackup/src/Generated/BackupProtectionContainerResource.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
...icesBackup/src/Generated/LongRunningOperation/BackupProtectionContainerOperationSource.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
20 changes: 4 additions & 16 deletions
20
...RecoveryServicesBackup/src/Generated/RestOperations/ProtectionContainersRestOperations.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...er.RecoveryServicesBackup/tests/Azure.ResourceManager.RecoveryServicesBackup.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<ProjectReference Include="..\src\Azure.ResourceManager.RecoveryServicesBackup.csproj" /> | ||
<PackageReference Include="Azure.ResourceManager.RecoveryServices" /> | ||
<PackageReference Include="Azure.ResourceManager.Storage" /> | ||
</ItemGroup> | ||
</Project> |
67 changes: 67 additions & 0 deletions
67
...ourceManager.RecoveryServicesBackup/tests/ScenarioTests/BackupProtectionContainerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Threading.Tasks; | ||
using Azure.Core; | ||
using Azure.Core.TestFramework; | ||
using Azure.ResourceManager.RecoveryServices; | ||
using Azure.ResourceManager.RecoveryServices.Models; | ||
using Azure.ResourceManager.RecoveryServicesBackup.Models; | ||
using Azure.ResourceManager.Storage; | ||
using Azure.ResourceManager.Storage.Models; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.ResourceManager.RecoveryServicesBackup.Tests | ||
{ | ||
public class BackupProtectionContainerTests : RecoveryServicesBackupManagementTestBase | ||
{ | ||
public BackupProtectionContainerTests(bool isAsnyc) | ||
: base(isAsnyc)//, RecordedTestMode.Record) | ||
{ | ||
} | ||
|
||
[Test] | ||
public async Task CreateTest() | ||
{ | ||
var sub = await Client.GetDefaultSubscriptionAsync(); | ||
var rg = await CreateResourceGroup(sub, "sdktest", AzureLocation.EastUS); | ||
|
||
var storageName = Recording.GenerateAssetName("teststorage"); | ||
var storageData = new StorageAccountCreateOrUpdateContent( | ||
new StorageSku(StorageSkuName.StandardGrs), StorageKind.StorageV2, AzureLocation.EastUS); | ||
var storage = (await rg.GetStorageAccounts() | ||
.CreateOrUpdateAsync(WaitUntil.Completed, storageName, storageData)).Value; | ||
|
||
var vaultName = Recording.GenerateAssetName("testvalut"); | ||
var vaultData = new RecoveryServicesVaultData(AzureLocation.EastUS) | ||
{ | ||
Sku = new RecoveryServicesSku(RecoveryServicesSkuName.RS0) { Tier = "Standard" }, | ||
Properties = new RecoveryServicesVaultProperties() | ||
{ | ||
PublicNetworkAccess = VaultPublicNetworkAccess.Enabled | ||
} | ||
}; | ||
var vault = (await rg.GetRecoveryServicesVaults().CreateOrUpdateAsync(WaitUntil.Completed, vaultName, vaultData)).Value; | ||
|
||
var containerName = $"StorageContainer;Storage;{rg.Data.Name};{storageName}"; | ||
var containerData = new BackupProtectionContainerData(AzureLocation.EastUS) | ||
{ | ||
Properties = new StorageContainer() | ||
{ | ||
FriendlyName = storageName, | ||
BackupManagementType = BackupManagementType.AzureStorage, | ||
SourceResourceId = storage.Id, | ||
AcquireStorageAccountLock = AcquireStorageAccountLock.Acquire | ||
} | ||
}; | ||
var container = (await rg.GetBackupProtectionContainers() | ||
.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, "Azure", containerName, containerData)).Value; | ||
Assert.AreEqual(container.Data.Properties.RegistrationStatus, "Registered"); | ||
Assert.AreEqual(container.Data.Name, containerName); | ||
|
||
// Remove the auto-lock before we delete the resource group | ||
var deleteLock = (await storage.GetManagementLocks().GetAsync("AzureBackupProtectionLock")).Value; | ||
await deleteLock.DeleteAsync(WaitUntil.Completed); | ||
} | ||
} | ||
} |