Skip to content

Commit d02818e

Browse files
authored
Support DnsEndpointType when creating a storage account (#21256)
1 parent 278b97a commit d02818e

File tree

8 files changed

+777
-184
lines changed

8 files changed

+777
-184
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,5 +295,12 @@ public void TestAzureStorageLocalUserSftp()
295295
{
296296
TestRunner.RunTestScript("Test-AzureStorageLocalUserSftp");
297297
}
298+
299+
[Fact]
300+
[Trait(Category.AcceptanceType, Category.CheckIn)]
301+
public void TestStorageAccountDnsEndpointType()
302+
{
303+
TestRunner.RunTestScript("Test-StorageAccountDnsEndpointType");
304+
}
298305
}
299306
}

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,4 +2522,43 @@ function Test-AzureStorageLocalUserSftp
25222522
# Cleanup
25232523
Clean-ResourceGroup $rgname
25242524
}
2525+
}
2526+
2527+
<#
2528+
.SYNOPSIS
2529+
Test StorageAccountDNSEndpointType
2530+
.DESCRIPTION
2531+
SmokeTest
2532+
#>
2533+
function Test-StorageAccountDNSEndpointType
2534+
{
2535+
# Setup
2536+
$rgname = Get-StorageManagementTestResourceName;
2537+
2538+
try
2539+
{
2540+
# Test
2541+
$stoname = 'sto' + $rgname
2542+
$stoname2 = 'sto2' + $rgname
2543+
$stotype = 'Standard_LRS'
2544+
$loc = Get-ProviderLocation ResourceManagement;
2545+
$kind = 'StorageV2'
2546+
New-AzResourceGroup -Name $rgname -Location $loc;
2547+
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -SkuName $stotype -DnsEndpointType AzureDnsZone
2548+
$account = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname
2549+
Assert-AreEqual $account.StorageAccountName $stoname
2550+
Assert-AreEqual $account.DnsEndpointType AzureDnsZone
2551+
2552+
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname2 -Location $loc -SkuName $stotype -DnsEndpointType Standard
2553+
$account2 = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname2
2554+
Assert-AreEqual $account2.StorageAccountName $stoname2
2555+
Assert-AreEqual $account2.DnsEndpointType Standard
2556+
2557+
Remove-AzStorageAccount -Force -ResourceGroupName $rgname -Name $stoname;
2558+
}
2559+
finally
2560+
{
2561+
# Cleanup
2562+
Clean-ResourceGroup $rgname
2563+
}
25252564
}

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

Lines changed: 676 additions & 175 deletions
Large diffs are not rendered by default.

src/Storage/Storage.Management/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Supported create storage account with DnsEndpointType
22+
- `New-AzStorageAccount`
2123
* Fixed file cmdlets potential context issue when the current context doesn't match with the credential of input Azure File object
2224
- `Close-AzStorageFileHandle`
2325
- `Get-AzStorageFile`

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public PSStorageAccount(StorageModels.StorageAccount storageAccount)
7373
this.EnableSftp = storageAccount.IsSftpEnabled;
7474
this.EnableLocalUser = storageAccount.IsLocalUserEnabled;
7575
this.AllowedCopyScope = storageAccount.AllowedCopyScope;
76+
this.DnsEndpointType= storageAccount.DnsEndpointType;
7677
}
7778
public bool? AllowCrossTenantReplication { get; set; }
7879

@@ -166,6 +167,7 @@ public PSStorageAccount(StorageModels.StorageAccount storageAccount)
166167

167168
public PSImmutableStorageAccount ImmutableStorageWithVersioning { get; set; }
168169
public PSStorageAccountSkuConversionStatus StorageAccountSkuConversionStatus { get; set; }
170+
public string DnsEndpointType { get; set; }
169171

170172

171173
public static PSStorageAccount Create(StorageModels.StorageAccount storageAccount, IStorageManagementClient client)

src/Storage/Storage.Management/StorageAccount/NewAzureStorageAccount.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,14 @@ public int ImmutabilityPeriod
619619
[ValidateNotNullOrEmpty]
620620
public string AllowedCopyScope { get; set; }
621621

622+
[Parameter(
623+
Mandatory = false,
624+
HelpMessage = "Specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, " +
625+
"which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Possible values include: 'Standard', 'AzureDnsZone'.")]
626+
[PSArgumentCompleter("Standard", "AzureDnsZone")]
627+
[ValidateNotNullOrEmpty]
628+
public string DnsEndpointType { get; set; }
629+
622630
public override void ExecuteCmdlet()
623631
{
624632
base.ExecuteCmdlet();
@@ -890,10 +898,14 @@ public override void ExecuteCmdlet()
890898
{
891899
createParameters.IsLocalUserEnabled = this.enableLocalUser;
892900
}
893-
if(this.AllowedCopyScope != null)
901+
if (this.AllowedCopyScope != null)
894902
{
895903
createParameters.AllowedCopyScope = this.AllowedCopyScope;
896904
}
905+
if (this.DnsEndpointType != null)
906+
{
907+
createParameters.DnsEndpointType = this.DnsEndpointType;
908+
}
897909

898910
var createAccountResponse = this.StorageClient.StorageAccounts.Create(
899911
this.ResourceGroupName,

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

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ New-AzStorageAccount [-ResourceGroupName] <String> [-Name] <String> [-SkuName] <
2828
[-MinimumTlsVersion <String>] [-AllowSharedKeyAccess <Boolean>] [-EnableNfsV3 <Boolean>]
2929
[-AllowCrossTenantReplication <Boolean>] [-DefaultSharePermission <String>] [-EdgeZone <String>]
3030
[-PublicNetworkAccess <String>] [-EnableAccountLevelImmutability] [-ImmutabilityPeriod <Int32>]
31-
[-ImmutabilityPolicyState <String>] [-AllowedCopyScope <String>] [-DefaultProfile <IAzureContextContainer>]
32-
[-RoutingChoice <String>] [<CommonParameters>]
31+
[-ImmutabilityPolicyState <String>] [-AllowedCopyScope <String>] [-DnsEndpointType <String>]
32+
[-DefaultProfile <IAzureContextContainer>] [-RoutingChoice <String>] [<CommonParameters>]
3333
```
3434

3535
### AzureActiveDirectoryKerberosForFile
@@ -48,8 +48,8 @@ New-AzStorageAccount [-ResourceGroupName] <String> [-Name] <String> [-SkuName] <
4848
[-AllowSharedKeyAccess <Boolean>] [-EnableNfsV3 <Boolean>] [-AllowCrossTenantReplication <Boolean>]
4949
[-DefaultSharePermission <String>] [-EdgeZone <String>] [-PublicNetworkAccess <String>]
5050
[-EnableAccountLevelImmutability] [-ImmutabilityPeriod <Int32>] [-ImmutabilityPolicyState <String>]
51-
[-AllowedCopyScope <String>] [-DefaultProfile <IAzureContextContainer>] [-RoutingChoice <String>]
52-
[<CommonParameters>]
51+
[-AllowedCopyScope <String>] [-DnsEndpointType <String>] [-DefaultProfile <IAzureContextContainer>]
52+
[-RoutingChoice <String>] [<CommonParameters>]
5353
```
5454

5555
### ActiveDirectoryDomainServicesForFile
@@ -71,8 +71,8 @@ New-AzStorageAccount [-ResourceGroupName] <String> [-Name] <String> [-SkuName] <
7171
[-AllowSharedKeyAccess <Boolean>] [-EnableNfsV3 <Boolean>] [-AllowCrossTenantReplication <Boolean>]
7272
[-DefaultSharePermission <String>] [-EdgeZone <String>] [-PublicNetworkAccess <String>]
7373
[-EnableAccountLevelImmutability] [-ImmutabilityPeriod <Int32>] [-ImmutabilityPolicyState <String>]
74-
[-AllowedCopyScope <String>] [-DefaultProfile <IAzureContextContainer>] [-RoutingChoice <String>]
75-
[<CommonParameters>]
74+
[-AllowedCopyScope <String>] [-DnsEndpointType <String>] [-DefaultProfile <IAzureContextContainer>]
75+
[-RoutingChoice <String>] [<CommonParameters>]
7676
```
7777

7878
## DESCRIPTION
@@ -297,6 +297,7 @@ $account = New-AzStorageAccount -ResourceGroupName "MyResourceGroup" -Name "myst
297297
defaultAction="deny"})
298298
$account.EnableNfsV3
299299
```
300+
300301
```output
301302
True
302303
```
@@ -310,6 +311,7 @@ $account = New-AzStorageAccount -ResourceGroupName "MyResourceGroup" -Name "myst
310311
311312
$account.PublicNetworkAccess
312313
```
314+
313315
```output
314316
Disabled
315317
```
@@ -372,6 +374,13 @@ LastKeyRotationTimestamp : 3/3/2022 2:07:34 AM
372374

373375
This command creates a storage account with Keyvault from another tenant (access Keyvault with FederatedClientId).
374376

377+
### Example 18: Create account with DnsEndpointType as AzureDnsZone
378+
```powershell
379+
New-AzStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "mystorageaccount" -SkuName Standard_LRS -Location centraluseuap -Kind StorageV2 -DnsEndpointType AzureDnsZone
380+
```
381+
382+
The command creates a storage account with DnsEndpointType as AzureDnsZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier.
383+
375384
## PARAMETERS
376385

377386
### -AccessTier
@@ -651,6 +660,21 @@ Accept pipeline input: False
651660
Accept wildcard characters: False
652661
```
653662
663+
### -DnsEndpointType
664+
Specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Possible values include: 'Standard', 'AzureDnsZone'.
665+
666+
```yaml
667+
Type: System.String
668+
Parameter Sets: (All)
669+
Aliases:
670+
671+
Required: False
672+
Position: Named
673+
Default value: None
674+
Accept pipeline input: False
675+
Accept wildcard characters: False
676+
```
677+
654678
### -EdgeZone
655679
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
656680

src/Storage/Storage.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio Version 16
3-
VisualStudioVersion = 16.0.31112.23
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.4.33403.182
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Storage.Management", "Storage.Management\Storage.Management.csproj", "{A50AB133-5C04-4A17-9054-F8343683EC23}"
66
EndProject
@@ -26,6 +26,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestFx", "..\..\tools\TestF
2626
EndProject
2727
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Storage.Management.Sdk", "Storage.Management.Sdk\Storage.Management.Sdk.csproj", "{1BA85EC7-F8E5-423F-BA1B-B3918D0D59A3}"
2828
EndProject
29+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssemblyLoading", "..\Accounts\AssemblyLoading\AssemblyLoading.csproj", "{02615977-4499-48E6-9824-8B9F431E30EA}"
30+
EndProject
2931
Global
3032
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3133
Debug|Any CPU = Debug|Any CPU
@@ -76,6 +78,10 @@ Global
7678
{1BA85EC7-F8E5-423F-BA1B-B3918D0D59A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
7779
{1BA85EC7-F8E5-423F-BA1B-B3918D0D59A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
7880
{1BA85EC7-F8E5-423F-BA1B-B3918D0D59A3}.Release|Any CPU.Build.0 = Release|Any CPU
81+
{02615977-4499-48E6-9824-8B9F431E30EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
82+
{02615977-4499-48E6-9824-8B9F431E30EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
83+
{02615977-4499-48E6-9824-8B9F431E30EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
84+
{02615977-4499-48E6-9824-8B9F431E30EA}.Release|Any CPU.Build.0 = Release|Any CPU
7985
EndGlobalSection
8086
GlobalSection(SolutionProperties) = preSolution
8187
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)