Skip to content

Commit 01514ac

Browse files
authored
[Storage] Support AllowedCopyScope (#17321)
1 parent 2fc44aa commit 01514ac

File tree

8 files changed

+1261
-1
lines changed

8 files changed

+1261
-1
lines changed

src/Storage/Storage.Management.Test/ScenarioTests/StorageAccountTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,13 @@ public void TestAzureStorageAccountWorm()
280280
public void TestAzureStorageLocalUserSftp()
281281
{
282282
TestRunner.RunTestScript("Test-AzureStorageLocalUserSftp");
283+
}
284+
285+
[Fact]
286+
[Trait(Category.AcceptanceType, Category.CheckIn)]
287+
public void TestStorageAccountAllowedCopyScope()
288+
{
289+
TestRunner.RunTestScript("Test-StorageAccountAllowedCopyScope");
283290
}
284291
}
285292
}

src/Storage/Storage.Management.Test/ScenarioTests/StorageAccountTests.ps1

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,3 +2268,47 @@ function Test-AzureStorageLocalUserSftp
22682268
Clean-ResourceGroup $rgname
22692269
}
22702270
}
2271+
2272+
<#
2273+
.SYNOPSIS
2274+
Test Test-StorageAccountAllowedCopyScope
2275+
.DESCRIPTION
2276+
SmokeTest
2277+
#>
2278+
function Test-StorageAccountAllowedCopyScope
2279+
{
2280+
# Setup
2281+
$rgname = Get-StorageManagementTestResourceName;
2282+
2283+
try
2284+
{
2285+
# Test
2286+
$stoname = 'sto' + $rgname;
2287+
$stotype = 'Standard_LRS';
2288+
$loc = Get-ProviderLocation ResourceManagement;
2289+
$kind = 'StorageV2'
2290+
2291+
New-AzResourceGroup -Name $rgname -Location $loc;
2292+
Write-Output ("Resource Group created")
2293+
2294+
# new account
2295+
$loc = Get-ProviderLocation_Canary ResourceManagement;
2296+
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -SkuName $stotype -AllowedCopyScope AAD
2297+
2298+
Retry-IfException { $global:sto = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname; }
2299+
Assert-AreEqual "AAD" $sto.AllowedCopyScope;
2300+
2301+
# Update account
2302+
Set-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -AllowedCopyScope PrivateLink
2303+
2304+
Retry-IfException { $global:sto = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname; }
2305+
Assert-AreEqual "PrivateLink" $sto.AllowedCopyScope;
2306+
2307+
Remove-AzStorageAccount -Force -ResourceGroupName $rgname -Name $stoname;
2308+
}
2309+
finally
2310+
{
2311+
# Cleanup
2312+
Clean-ResourceGroup $rgname
2313+
}
2314+
}

src/Storage/Storage.Management.Test/SessionRecords/Microsoft.Azure.Commands.Management.Storage.Test.ScenarioTests.StorageAccountTests/TestStorageAccountAllowedCopyScope.json

Lines changed: 1185 additions & 0 deletions
Large diffs are not rendered by default.

src/Storage/Storage.Management/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Supported create/upgrade storage account with AllowedCopyScope
22+
- `New-AzStorageAccount`
23+
- `Set-AzStorageAccount`
2124

2225
## Version 4.3.0
2326
* Supported download blob from managed disk account with Sas Uri and bearer token

src/Storage/Storage.Management/Models/PSStorageAccount.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public PSStorageAccount(StorageModels.StorageAccount storageAccount)
7171
this.ImmutableStorageWithVersioning = storageAccount.ImmutableStorageWithVersioning is null ? null : new PSImmutableStorageAccount(storageAccount.ImmutableStorageWithVersioning);
7272
this.EnableSftp = storageAccount.IsSftpEnabled;
7373
this.EnableLocalUser = storageAccount.IsLocalUserEnabled;
74+
this.AllowedCopyScope = storageAccount.AllowedCopyScope;
7475
}
7576
public bool? AllowCrossTenantReplication { get; set; }
7677

@@ -161,6 +162,7 @@ public PSStorageAccount(StorageModels.StorageAccount storageAccount)
161162
public string PublicNetworkAccess { get; set; }
162163

163164
public PSImmutableStorageAccount ImmutableStorageWithVersioning { get; set; }
165+
public string AllowedCopyScope { get; set; }
164166

165167
public static PSStorageAccount Create(StorageModels.StorageAccount storageAccount, IStorageManagementClient client)
166168
{

src/Storage/Storage.Management/help/New-AzStorageAccount.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,16 @@ ImmutabilityPeriodSinceCreationInDays State AllowProtectedAppendWrites
302302
The command creates an account and enable account level immutability with versioning by '-EnableAccountLevelImmutability', then all the containers under this account will have object-level immutability enabled by default.
303303
The account is also created with a default account-level immutability policy which is inherited and applied to objects that do not possess an explicit immutability policy at the object level.
304304

305+
### Example 16: Create account with AllowedCopyScope as AAD
306+
```
307+
PS C:\> $account = New-AzStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "mystorageaccount" -SkuName Standard_LRS -Location centraluseuap -Kind StorageV2 -AllowedCopyScope AAD
308+
309+
PS C:\> $account.AllowedCopyScope
310+
AAD
311+
```
312+
313+
The command creates account with AllowedCopyScope as AAD.
314+
305315
## PARAMETERS
306316

307317
### -AccessTier

src/Storage/Storage.Management/help/Set-AzStorageAccount.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,16 @@ True
394394
This command updates a Storage account by enable Sftp and localuser.
395395
To run the command succssfully, the Storage account should already enable Hierarchical Namespace.
396396

397+
### Example 21: Update a Storage account by set AllowedCopyScope as PrivateLink
398+
```
399+
PS C:\> $account = Set-AzStorageAccount -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -AllowedCopyScope PrivateLink
400+
401+
PS C:\> $account.AllowedCopyScope
402+
PrivateLink
403+
```
404+
405+
The command updates a Storage account by set AllowedCopyScope as PrivateLink.
406+
397407
## PARAMETERS
398408

399409
### -AccessTier

src/Storage/Storage.Test/Storage.Test.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
<PropertyGroup>
1111
<RootNamespace>Microsoft.WindowsAzure.Management.$(PsModuleName)$(AzTestAssemblySuffix)</RootNamespace>
12-
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
1312
</PropertyGroup>
1413

1514
<ItemGroup>

0 commit comments

Comments
 (0)