Skip to content

Commit

Permalink
[RecoveryServicesBackup] Fix LRO issue (Azure#38784)
Browse files Browse the repository at this point in the history
* 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
3 people authored Sep 20, 2023
1 parent 0de0102 commit 2fb0d48
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 21 deletions.
1 change: 1 addition & 0 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
<PackageReference Update="Azure.ResourceManager.Network" Version="1.1.0" />
<PackageReference Update="Azure.ResourceManager.OperationalInsights" Version="1.0.0" />
<PackageReference Update="Azure.ResourceManager.PrivateDns" Version="1.0.0" />
<PackageReference Update="Azure.ResourceManager.RecoveryServices" Version="1.1.0" />
<PackageReference Update="Azure.ResourceManager.Resources" Version="1.4.0" />
<PackageReference Update="Azure.ResourceManager.Storage" Version="1.1.0" />
<PackageReference Update="Azure.ResourceManager.EventHubs" Version="1.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Breaking Changes

### Bugs Fixed
- Fix LRO in ProtectionContainers PUT operation

### Other Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup",
"Tag": ""
"Tag": "net/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup_6b115f5f54"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,9 @@ directive:
where: $.definitions.RecoveryPointProperties.properties.expiryTime
transform: >
$["format"] = "date-time";
# TODO: Remove this workaround once we have the swagger issue fixed
- from: bms.json
where: $.paths['/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}']
transform: >
$.put['x-ms-long-running-operation'] = true;
```
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>
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);
}
}
}

0 comments on commit 2fb0d48

Please sign in to comment.