Skip to content

Commit ff8f36a

Browse files
Migrate Storage from generation to main (#24489)
* Move Storage to main * Create UXMetadataIssues.csv * Update ChangeLog.md --------- Co-authored-by: Vincent Dai <[email protected]>
1 parent 4430f4a commit ff8f36a

File tree

322 files changed

+4735
-1158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

322 files changed

+4735
-1158
lines changed

src/Storage/Storage.Autorest/Az.Storage.psm1

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,37 +47,41 @@
4747

4848
# Ask for the shared functionality table
4949
$VTable = Register-AzModule
50-
50+
5151
# Tweaks the pipeline on module load
5252
$instance.OnModuleLoad = $VTable.OnModuleLoad
5353

5454
# Following two delegates are added for telemetry
5555
$instance.GetTelemetryId = $VTable.GetTelemetryId
5656
$instance.Telemetry = $VTable.Telemetry
57-
57+
58+
# Delegate to sanitize the output object
59+
$instance.SanitizeOutput = $VTable.SanitizerHandler
60+
61+
# Delegate to get the telemetry info
62+
$instance.GetTelemetryInfo = $VTable.GetTelemetryInfo
5863

5964
# Tweaks the pipeline per call
6065
$instance.OnNewRequest = $VTable.OnNewRequest
61-
66+
6267
# Gets shared parameter values
6368
$instance.GetParameterValue = $VTable.GetParameterValue
64-
69+
6570
# Allows shared module to listen to events from this module
6671
$instance.EventListener = $VTable.EventListener
67-
72+
6873
# Gets shared argument completers
6974
$instance.ArgumentCompleter = $VTable.ArgumentCompleter
70-
75+
7176
# The name of the currently selected Azure profile
7277
$instance.ProfileName = $VTable.ProfileName
7378

74-
7579
# Load the custom module
7680
$customModulePath = Join-Path $PSScriptRoot './custom/Az.Storage.custom.psm1'
7781
if(Test-Path $customModulePath) {
7882
$null = Import-Module -Name $customModulePath
7983
}
80-
84+
8185
# Export nothing to clear implicit exports
8286
Export-ModuleMember
8387

@@ -97,12 +101,12 @@
97101
# Load the last folder if no profile is selected
98102
$profileDirectory = $directories | Select-Object -Last 1
99103
}
100-
104+
101105
if($profileDirectory) {
102106
Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'"
103107
$exportsPath = $profileDirectory.FullName
104108
}
105-
109+
106110
if($exportsPath) {
107111
Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
108112
$cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath

src/Storage/Storage.Autorest/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
This directory contains the PowerShell module for the Storage service.
44

55
---
6-
76
## Info
87
- Modifiable: yes
98
- Generated: all
@@ -29,7 +28,7 @@ For information on how to develop for `Az.Storage`, see [how-to.md](how-to.md).
2928
3029
``` yaml
3130
# Please specify the commit id that includes your features to make sure generated codes stable.
32-
branch: 3e6b4ddca225530c27273d0f816466a905c0151b
31+
commit: 3e6b4ddca225530c27273d0f816466a905c0151b
3332
require:
3433
# readme.azure.noprofile.md is the common configuration file
3534
- $(this-folder)/../../readme.azure.noprofile.md
@@ -43,8 +42,6 @@ title: Storage
4342
subject-prefix: $(service-name)
4443
nested-object-to-string: true
4544
identity-correction-for-post: true
46-
use-extension:
47-
"@autorest/powershell": "4.x"
4845

4946
directive:
5047
- where:
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"resourceType": "storageAccounts/accountMigrations",
3+
"apiVersion": "2023-01-01",
4+
"learnMore": {
5+
"url": "https://learn.microsoft.com/powershell/module/az.storage"
6+
},
7+
"commands": [
8+
{
9+
"name": "Get-AzStorageAccountMigration",
10+
"description": "Gets the status of the ongoing migration for the specified storage account.",
11+
"path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/accountMigrations/{migrationName}",
12+
"help": {
13+
"learnMore": {
14+
"url": "https://learn.microsoft.com/powershell/module/az.storage/get-azstorageaccountmigration"
15+
},
16+
"parameterSets": [
17+
{
18+
"parameters": [
19+
"-AccountName <String>",
20+
"-ResourceGroupName <String>",
21+
"[-SubscriptionId <String[]>]"
22+
]
23+
}
24+
]
25+
},
26+
"examples": [
27+
{
28+
"description": "Gets the status of the ongoing migration for the specified storage account.",
29+
"parameters": [
30+
{
31+
"name": "-AccountName",
32+
"value": "[Path.accountName]"
33+
},
34+
{
35+
"name": "-ResourceGroupName",
36+
"value": "[Path.resourceGroupName]"
37+
},
38+
{
39+
"name": "-SubscriptionId",
40+
"value": "[Path.subscriptionId]"
41+
}
42+
]
43+
}
44+
]
45+
}
46+
]
47+
}

src/Storage/Storage.Autorest/exports/Get-AzStorageAccountMigration.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ param(
7777
[Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Path')]
7878
[Microsoft.Azure.PowerShell.Cmdlets.Storage.Models.IStorageIdentity]
7979
# Identity Parameter
80-
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
8180
${InputObject},
8281

8382
[Parameter()]
@@ -159,7 +158,13 @@ begin {
159158
GetViaIdentity = 'Az.Storage.private\Get-AzStorageAccountMigration_GetViaIdentity';
160159
}
161160
if (('Get') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
162-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
161+
$testPlayback = $false
162+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
163+
if ($testPlayback) {
164+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
165+
} else {
166+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
167+
}
163168
}
164169
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
165170
[Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/Storage/Storage.Autorest/exports/ProxyCmdletDefinitions.ps1

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ param(
7777
[Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Path')]
7878
[Microsoft.Azure.PowerShell.Cmdlets.Storage.Models.IStorageIdentity]
7979
# Identity Parameter
80-
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
8180
${InputObject},
8281

8382
[Parameter()]
@@ -159,7 +158,13 @@ begin {
159158
GetViaIdentity = 'Az.Storage.private\Get-AzStorageAccountMigration_GetViaIdentity';
160159
}
161160
if (('Get') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
162-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
161+
$testPlayback = $false
162+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
163+
if ($testPlayback) {
164+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
165+
} else {
166+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
167+
}
163168
}
164169
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
165170
[Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
@@ -296,7 +301,6 @@ param(
296301
[Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Path')]
297302
[Microsoft.Azure.PowerShell.Cmdlets.Storage.Models.IStorageIdentity]
298303
# Identity Parameter
299-
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
300304
${InputObject},
301305

302306
[Parameter(ParameterSetName='CustomerExpanded', Mandatory)]
@@ -432,7 +436,13 @@ begin {
432436
CustomerViaJsonString = 'Az.Storage.private\Start-AzStorageAccountMigration_CustomerViaJsonString';
433437
}
434438
if (('CustomerExpanded', 'CustomerViaJsonFilePath', 'CustomerViaJsonString') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
435-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
439+
$testPlayback = $false
440+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
441+
if ($testPlayback) {
442+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
443+
} else {
444+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
445+
}
436446
}
437447
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
438448
[Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/Storage/Storage.Autorest/exports/Start-AzStorageAccountMigration.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ param(
9999
[Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Path')]
100100
[Microsoft.Azure.PowerShell.Cmdlets.Storage.Models.IStorageIdentity]
101101
# Identity Parameter
102-
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
103102
${InputObject},
104103

105104
[Parameter(ParameterSetName='CustomerExpanded', Mandatory)]
@@ -235,7 +234,13 @@ begin {
235234
CustomerViaJsonString = 'Az.Storage.private\Start-AzStorageAccountMigration_CustomerViaJsonString';
236235
}
237236
if (('CustomerExpanded', 'CustomerViaJsonFilePath', 'CustomerViaJsonString') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
238-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
237+
$testPlayback = $false
238+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
239+
if ($testPlayback) {
240+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
241+
} else {
242+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
243+
}
239244
}
240245
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
241246
[Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/Storage/Storage.Autorest/generate-portal-ux.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ $instance = [Microsoft.Azure.PowerShell.Cmdlets.Storage.Module]::Instance
4242
$moduleInfo = Get-Module -Name $moduleName
4343
$parameterSetsInfo = Get-Module -Name "$moduleName.private"
4444

45-
$buildinFunctions = @("Export-CmdletSurface", "Export-ExampleStub", "Export-FormatPs1xml", "Export-HelpMarkdown", "Export-ModelSurface", "Export-ProxyCmdlet", "Export-Psd1", "Export-TestStub", "Get-CommonParameter", "Get-ModuleGuid", "Get-ScriptCmdlet")
46-
4745
function Test-FunctionSupported()
4846
{
4947
[CmdletBinding()]
@@ -53,12 +51,12 @@ function Test-FunctionSupported()
5351
$FunctionName
5452
)
5553

56-
If ($buildinfunctions.Contains($FunctionName)) {
54+
If (-not $FunctionName.Contains("_")) {
5755
return $false
5856
}
5957

6058
$cmdletName, $parameterSetName = $FunctionName.Split("_")
61-
If ($parameterSetName.Contains("List") -or $parameterSetName.Contains("ViaIdentity")) {
59+
If ($parameterSetName.Contains("List") -or $parameterSetName.Contains("ViaIdentity") -or $parameterSetName.Contains("ViaJson")) {
6260
return $false
6361
}
6462
If ($cmdletName.StartsWith("New") -or $cmdletName.StartsWith("Set") -or $cmdletName.StartsWith("Update")) {
@@ -311,7 +309,7 @@ function New-MetadataForCmdlet()
311309
return $result
312310
}
313311

314-
$parameterSets = $parameterSetsInfo.ExportedCmdlets.Keys | Where-Object { Test-functionSupported($_) }
312+
$parameterSets = $parameterSetsInfo.ExportedCmdlets.Keys | Where-Object { Test-FunctionSupported($_) }
315313
$resourceTypes = @{}
316314
foreach ($parameterSetName in $parameterSets)
317315
{

src/Storage/Storage.Autorest/generated/Module.cs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.Storage
1717
using SignalDelegate = global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Threading.Tasks.Task>;
1818
using EventListenerDelegate = global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Threading.Tasks.Task>, global::System.Management.Automation.InvocationInfo, string, string, string, global::System.Exception, global::System.Threading.Tasks.Task>;
1919
using NextDelegate = global::System.Func<global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken, global::System.Action, global::System.Func<string, global::System.Threading.CancellationToken, global::System.Func<global::System.EventArgs>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task<global::System.Net.Http.HttpResponseMessage>>;
20+
using SanitizerDelegate = global::System.Action<object, string>;
21+
using GetTelemetryInfoDelegate = global::System.Func<string, global::System.Collections.Generic.Dictionary<global::System.String,global::System.String>>;
2022

2123
/// <summary>A class that contains the module-common code and data.</summary>
2224
public partial class Module
@@ -26,12 +28,20 @@ public partial class Module
2628

2729
public global::System.Net.Http.HttpClientHandler _handler = new global::System.Net.Http.HttpClientHandler();
2830

31+
private static bool _init = false;
32+
33+
private static readonly global::System.Object _initLock = new global::System.Object();
34+
35+
private static Microsoft.Azure.PowerShell.Cmdlets.Storage.Module _instance;
36+
2937
/// <summary>the ISendAsync pipeline instance</summary>
3038
private Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.HttpPipeline _pipeline;
3139

3240
/// <summary>the ISendAsync pipeline instance (when proxy is enabled)</summary>
3341
private Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.HttpPipeline _pipelineWithProxy;
3442

43+
private static readonly global::System.Object _singletonLock = new global::System.Object();
44+
3545
public bool _useProxy = false;
3646

3747
public global::System.Net.WebProxy _webProxy = new global::System.Net.WebProxy();
@@ -51,11 +61,11 @@ public partial class Module
5161
/// <summary>The delegate to get the telemetry Id.</summary>
5262
public GetTelemetryIdDelegate GetTelemetryId { get; set; }
5363

54-
/// <summary>Backing field for <see cref="Instance" /> property.</summary>
55-
private static Microsoft.Azure.PowerShell.Cmdlets.Storage.Module _instance;
64+
/// <summary>The delegate to get the telemetry info.</summary>
65+
public GetTelemetryInfoDelegate GetTelemetryInfo { get; set; }
5666

5767
/// <summary>the singleton of this module class</summary>
58-
public static Microsoft.Azure.PowerShell.Cmdlets.Storage.Module Instance => Microsoft.Azure.PowerShell.Cmdlets.Storage.Module._instance?? (Microsoft.Azure.PowerShell.Cmdlets.Storage.Module._instance = new Microsoft.Azure.PowerShell.Cmdlets.Storage.Module());
68+
public static Microsoft.Azure.PowerShell.Cmdlets.Storage.Module Instance { get { if (_instance == null) { lock (_singletonLock) { if (_instance == null) { _instance = new Module(); }}} return _instance; } }
5969

6070
/// <summary>The Name of this module</summary>
6171
public string Name => @"Az.Storage";
@@ -72,6 +82,9 @@ public partial class Module
7282
/// <summary>The ResourceID for this module (azure arm).</summary>
7383
public string ResourceId => @"Az.Storage";
7484

85+
/// <summary>The delegate to call in WriteObject to sanitize the output object.</summary>
86+
public SanitizerDelegate SanitizeOutput { get; set; }
87+
7588
/// <summary>The delegate for creating a telemetry.</summary>
7689
public TelemetryDelegate Telemetry { get; set; }
7790

@@ -117,9 +130,17 @@ public Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.HttpPipeline CreatePip
117130
/// <summary>Initialization steps performed after the module is loaded.</summary>
118131
public void Init()
119132
{
120-
OnModuleLoad?.Invoke( ResourceId, Name ,(step)=> { _pipeline.Prepend(step); } , (step)=> { _pipeline.Append(step); } );
121-
OnModuleLoad?.Invoke( ResourceId, Name ,(step)=> { _pipelineWithProxy.Prepend(step); } , (step)=> { _pipelineWithProxy.Append(step); } );
122-
CustomInit();
133+
if (_init == false)
134+
{
135+
lock (_initLock) {
136+
if (_init == false) {
137+
OnModuleLoad?.Invoke( ResourceId, Name ,(step)=> { _pipeline.Prepend(step); } , (step)=> { _pipeline.Append(step); } );
138+
OnModuleLoad?.Invoke( ResourceId, Name ,(step)=> { _pipelineWithProxy.Prepend(step); } , (step)=> { _pipelineWithProxy.Append(step); } );
139+
CustomInit();
140+
_init = true;
141+
}
142+
}
143+
}
123144
}
124145

125146
/// <summary>Creates the module instance.</summary>

src/Storage/Storage.Autorest/generated/api/Models/AccountImmutabilityPolicyProperties.json.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ internal AccountImmutabilityPolicyProperties(Microsoft.Azure.PowerShell.Cmdlets.
6565
{
6666
return;
6767
}
68-
{_immutabilityPeriodSinceCreationInDay = If( json?.PropertyT<Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.Json.JsonNumber>("immutabilityPeriodSinceCreationInDays"), out var __jsonImmutabilityPeriodSinceCreationInDays) ? (int?)__jsonImmutabilityPeriodSinceCreationInDays : ImmutabilityPeriodSinceCreationInDay;}
69-
{_state = If( json?.PropertyT<Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.Json.JsonString>("state"), out var __jsonState) ? (string)__jsonState : (string)State;}
70-
{_allowProtectedAppendWrite = If( json?.PropertyT<Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.Json.JsonBoolean>("allowProtectedAppendWrites"), out var __jsonAllowProtectedAppendWrites) ? (bool?)__jsonAllowProtectedAppendWrites : AllowProtectedAppendWrite;}
68+
{_immutabilityPeriodSinceCreationInDay = If( json?.PropertyT<Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.Json.JsonNumber>("immutabilityPeriodSinceCreationInDays"), out var __jsonImmutabilityPeriodSinceCreationInDays) ? (int?)__jsonImmutabilityPeriodSinceCreationInDays : _immutabilityPeriodSinceCreationInDay;}
69+
{_state = If( json?.PropertyT<Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.Json.JsonString>("state"), out var __jsonState) ? (string)__jsonState : (string)_state;}
70+
{_allowProtectedAppendWrite = If( json?.PropertyT<Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.Json.JsonBoolean>("allowProtectedAppendWrites"), out var __jsonAllowProtectedAppendWrites) ? (bool?)__jsonAllowProtectedAppendWrites : _allowProtectedAppendWrite;}
7171
AfterFromJson(json);
7272
}
7373

0 commit comments

Comments
 (0)