Skip to content

Commit 81e6ec2

Browse files
authored
Update prompt message of deleting a share snapshot and the output format of getting a share snapshot (#23925)
1 parent 00e9153 commit 81e6ec2

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

src/Storage/Storage.Management/ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Updated the prompt message when deleting a share snapshot and the output format when listing
22+
- `Remove-AzStorageShare`
23+
- `Remove-AzRmStorageSahre`
24+
- `Get-AzRmStorageShare`
2125

2226
## Version 6.1.0
2327
* Defaults of AllowBlobPublicAccess and AllowCrossTenantReplication when creating a storage account were set to false by server changes. Please refer to https://techcommunity.microsoft.com/t5/azure-storage-blog/azure-storage-updating-some-default-security-settings-on-new/ba-p/3819554

src/Storage/Storage.Management/File/RemoveAzureStorageShare.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public class RemoveAzureStorageShareCommand : StorageFileBaseCmdlet
137137
[ValidateNotNullOrEmpty]
138138
public DateTime? SnapshotTime { get; set; }
139139

140-
[Parameter(HelpMessage = "Force to remove the Share and all content in it")]
140+
[Parameter(HelpMessage = "Force to remove the Share(snapshot) and all content in it")]
141141
public SwitchParameter Force { get; set; }
142142

143143
[Parameter(
@@ -200,6 +200,7 @@ public override void ExecuteCmdlet()
200200
this.ResourceGroupName = InputObject.ResourceGroupName;
201201
this.StorageAccountName = InputObject.StorageAccountName;
202202
this.Name = InputObject.Name;
203+
this.SnapshotTime = InputObject.SnapshotTime is null ? null : InputObject.SnapshotTime;
203204
break;
204205
case AccountObjectParameterSet:
205206
case AccountObjectSnapshotParameterSet:
@@ -215,13 +216,24 @@ public override void ExecuteCmdlet()
215216
default:
216217
break;
217218
}
218-
if (Force.IsPresent || ShouldContinue(String.Format("Remove Share and all files in it: {0}", this.Name), ""))
219+
220+
String promptMessage;
221+
if (this.SnapshotTime != null)
222+
{
223+
promptMessage = String.Format("Remove share snapshot and all files in it: {0}, SnapshotTime: {1}", this.Name, this.SnapshotTime.Value.ToUniversalTime().ToString("o"));
224+
}
225+
else
226+
{
227+
promptMessage = String.Format("Remove Share and all files in it: {0}", this.Name);
228+
}
229+
230+
if (Force.IsPresent || ShouldContinue(promptMessage, ""))
219231
{
220232
this.StorageClient.FileShares.Delete(
221233
this.ResourceGroupName,
222234
this.StorageAccountName,
223235
this.Name,
224-
xMsSnapshot: this.SnapshotTime is null ? null : this.SnapshotTime.Value.ToUniversalTime().ToString("o"),
236+
xMsSnapshot: this.SnapshotTime?.ToUniversalTime().ToString("o"),
225237
include: include.ToLower());
226238

227239
if (PassThru.IsPresent)

src/Storage/Storage.Management/Storage.Management.format.ps1xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@
579579
</TableColumnHeader>
580580
<TableColumnHeader>
581581
<Alignment>Left</Alignment>
582-
<Label>snapshotTime</Label>
582+
<Label>SnapshotTime</Label>
583583
</TableColumnHeader>
584584
</TableHeaders>
585585
<TableRowEntries>
@@ -615,7 +615,7 @@
615615
</TableColumnItem>
616616
<TableColumnItem>
617617
<Alignment>Left</Alignment>
618-
<ScriptBlock>$_.snapshotTime.ToUniversalTime().ToString("s")+"Z"</ScriptBlock>
618+
<ScriptBlock>$_.SnapshotTime.ToUniversalTime().ToString("s")+"Z"</ScriptBlock>
619619
</TableColumnItem>
620620
</TableColumnItems>
621621
</TableRowEntry>

src/Storage/Storage.Management/help/Remove-AzRmStorageShare.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Accept wildcard characters: False
118118
```
119119
120120
### -Force
121-
Force to remove the Share and all content in it
121+
Force to remove the Share(snapshot) and all content in it
122122
123123
```yaml
124124
Type: System.Management.Automation.SwitchParameter

src/Storage/Storage/File/Cmdlet/RemoveAzureStorageShare.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public override void ExecuteCmdlet()
107107
{
108108
share = AzureStorageFileShare.GetTrack2FileShareClient(this.Share, (AzureStorageContext)this.Context, this.ClientOptions);
109109
}
110+
this.SnapshotTime = this.Share.SnapshotTime == null ? null : this.Share.SnapshotTime;
110111

111112
// Build and set storage context for the output object when
112113
// 1. input track1 object and storage context is missing 2. the current context doesn't match the context of the input object
@@ -138,7 +139,17 @@ public override void ExecuteCmdlet()
138139
throw new PSArgumentException(string.Format(CultureInfo.InvariantCulture, "'IncludeAllSnapshot' should only be specified to delete a base share, and should not be specified to delete a Share snapshot: {0}", share.Uri));
139140
}
140141

141-
if (force || ShareIsEmpty(share) || ShouldContinue(string.Format("Remove share and all content in it: {0}", share.Name), ""))
142+
string promptMessage;
143+
if (this.SnapshotTime != null)
144+
{
145+
promptMessage = string.Format("Remove share snapshot and all files in it: {0}, SnapshotTime: {1}", share.Name, this.SnapshotTime.Value.ToUniversalTime().ToString("o"));
146+
}
147+
else
148+
{
149+
promptMessage = string.Format("Remove share and all content in it: {0}", share.Name);
150+
}
151+
152+
if (force || ShareIsEmpty(share) || ShouldContinue(promptMessage, ""))
142153
{
143154
bool includeSnapshots = false;
144155
bool retryDeleteSnapshot = false;

0 commit comments

Comments
 (0)