Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storage] Support Extended location #14718

Merged
merged 1 commit into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,12 @@ public void TestNewSetAzureStorageAccountAllowSharedKeyAccess()
{
TestRunner.RunTestScript("Test-NewSetAzureStorageAccountAllowSharedKeyAccess");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewAzureStorageAccountEdgeZone()
{
TestRunner.RunTestScript("Test-NewAzureStorageAccountEdgeZone");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1553,4 +1553,46 @@ function Test-NewSetAzStorageAccount_RoutingPreference
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Test Test-NewAzureStorageAccountEdgeZone
.DESCRIPTION
SmokeTest
#>
function Test-NewAzureStorageAccountEdgeZone
{
# Setup
$rgname = Get-StorageManagementTestResourceName;

try
{
# Test
$stoname = 'sto' + $rgname;
$stotype = 'Premium_LRS';
$loc = Get-ProviderLocation ResourceManagement;
$kind = 'StorageV2'

New-AzResourceGroup -Name $rgname -Location $loc;
Write-Output ("Resource Group created")

# new account
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -SkuName $stotype -EdgeZone "microsoftlosangeles1"

Retry-IfException { $global:sto = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname; }
Assert-AreEqual $stoname $sto.StorageAccountName;
Assert-AreEqual $stotype $sto.Sku.Name;
Assert-AreEqual $loc.ToLower().Replace(" ", "") $sto.Location;
Assert-AreEqual $kind $sto.Kind;
Assert-AreEqual "EdgeZone" $sto.ExtendedLocation.Type;
Assert-AreEqual "microsoftlosangeles1" $sto.ExtendedLocation.Name;

Remove-AzStorageAccount -Force -ResourceGroupName $rgname -Name $stoname;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Storage/Storage.Management/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- Additional information about change #1
-->
## Upcoming Release
* Supported EdgeZone in create storage account
- `New-AzStorageAccount`
* Fixed an issue that delete immutable blob will prompt incorrect message.
- `Remove-AzStorageAccount`
* Fixed copy blob fail with source context as Oauth [#14662]
Expand Down
18 changes: 18 additions & 0 deletions src/Storage/Storage.Management/Models/PSStorageAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public PSStorageAccount(StorageModels.StorageAccount storageAccount)
this.RoutingPreference = PSRoutingPreference.ParsePSRoutingPreference(storageAccount.RoutingPreference);
this.BlobRestoreStatus = storageAccount.BlobRestoreStatus is null ? null : new PSBlobRestoreStatus(storageAccount.BlobRestoreStatus);
this.EnableNfsV3 = storageAccount.EnableNfsV3;
this.ExtendedLocation = storageAccount.ExtendedLocation is null ? null : new PSExtendedLocation(storageAccount.ExtendedLocation);
this.AllowSharedKeyAccess = storageAccount.AllowSharedKeyAccess;

}
Expand Down Expand Up @@ -140,6 +141,8 @@ public PSStorageAccount(StorageModels.StorageAccount storageAccount)

public bool? AllowSharedKeyAccess { get; set; }

public PSExtendedLocation ExtendedLocation { get; set; }

public static PSStorageAccount Create(StorageModels.StorageAccount storageAccount, IStorageManagementClient client)
{
var result = new PSStorageAccount(storageAccount);
Expand Down Expand Up @@ -207,4 +210,19 @@ public Sku ParseSku()
return new Sku(Name, Tier);
}
}

public class PSExtendedLocation
{
public PSExtendedLocation()
{ }

public PSExtendedLocation(ExtendedLocation extendedLocation)
{
this.Name = extendedLocation.Name;
this.Type = extendedLocation.Type;
}

public string Name { get; set; }
public string Type { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@ public bool AllowSharedKeyAccess
}
private bool? allowSharedKeyAccess = null;

[Parameter(Mandatory = false, HelpMessage = "Set the extended location name for EdgeZone. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location")]
[ValidateNotNullOrEmpty]
public string EdgeZone { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
Expand Down Expand Up @@ -512,6 +516,14 @@ public override void ExecuteCmdlet()
{
createParameters.AllowSharedKeyAccess = allowSharedKeyAccess;
}
if(this.EdgeZone != null)
{
createParameters.ExtendedLocation = new ExtendedLocation()
{
Type = ExtendedLocationTypes.EdgeZone,
Name = this.EdgeZone
};
}

var createAccountResponse = this.StorageClient.StorageAccounts.Create(
this.ResourceGroupName,
Expand Down
32 changes: 30 additions & 2 deletions src/Storage/Storage.Management/help/New-AzStorageAccount.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ New-AzStorageAccount [-ResourceGroupName] <String> [-Name] <String> [-SkuName] <
[-EnableLargeFileShare] [-PublishMicrosoftEndpoint <Boolean>] [-PublishInternetEndpoint <Boolean>] [-AsJob]
[-EncryptionKeyTypeForTable <String>] [-EncryptionKeyTypeForQueue <String>] [-RequireInfrastructureEncryption]
[-AllowBlobPublicAccess <Boolean>] [-MinimumTlsVersion <String>] [-AllowSharedKeyAccess <Boolean>]
[-DefaultProfile <IAzureContextContainer>] [-RoutingChoice <String>] [<CommonParameters>]
[-EdgeZone <String>] [-DefaultProfile <IAzureContextContainer>] [-RoutingChoice <String>] [<CommonParameters>]
```

### ActiveDirectoryDomainServicesForFile
Expand All @@ -37,7 +37,7 @@ New-AzStorageAccount [-ResourceGroupName] <String> [-Name] <String> [-SkuName] <
[-ActiveDirectoryDomainSid <String>] [-ActiveDirectoryAzureStorageSid <String>] [-AsJob]
[-EncryptionKeyTypeForTable <String>] [-EncryptionKeyTypeForQueue <String>] [-RequireInfrastructureEncryption]
[-AllowBlobPublicAccess <Boolean>] [-MinimumTlsVersion <String>] [-AllowSharedKeyAccess <Boolean>]
[-DefaultProfile <IAzureContextContainer>] [-RoutingChoice <String>] [<CommonParameters>]
[-EdgeZone <String>] [-DefaultProfile <IAzureContextContainer>] [-RoutingChoice <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -172,6 +172,19 @@ InternetEndpoints : {"Blob":"https://mystorageaccount-internetrouting.blob.core

This command creates a Storage account with RoutingPreference setting: PublishMicrosoftEndpoint and PublishInternetEndpoint as true, and RoutingChoice as MicrosoftRouting.

### Example 11: Create a Storage account with EdgeZone
```powershell
PS C:\>$account = New-AzStorageAccount -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -SkuName Premium_LRS -Location westus -EdgeZone "microsoftlosangeles1"

PS C:\>$account.ExtendedLocation

Name Type
---- ----
microsoftlosangeles1 EdgeZone
```

This command creates a Storage account with EdgeZone as "microsoftlosangeles1", then show the created account ExtendedLocation properties.

## PARAMETERS

### -AccessTier
Expand Down Expand Up @@ -375,6 +388,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -EdgeZone
Set the extended location name for EdgeZone. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -EnableActiveDirectoryDomainServicesForFile
Enable Azure Files Active Directory Domain Service Authentication for the storage account.

Expand Down