Skip to content

Commit 72e52e9

Browse files
committed
Upgrade to XSCL 9.0 and support soft-delete
1 parent ff8bb75 commit 72e52e9

27 files changed

+653
-57
lines changed

src/Common/Commands.Common.Storage/Adapters/WindowsAzure.Storage.8/ResourceModel/AzureStorageBlob.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ public class AzureStorageBlob : AzureStorageBase
3737
/// </summary>
3838
public long Length { get; private set; }
3939

40+
/// <summary>
41+
/// Blob IsDeleted
42+
/// </summary>
43+
public bool IsDeleted { get; private set; }
44+
45+
/// <summary>
46+
/// Blob IsDeleted
47+
/// </summary>
48+
public int? RemainingDaysBeforePermanentDelete { get; private set; }
49+
4050
/// <summary>
4151
/// Blob content type
4252
/// </summary>
@@ -67,6 +77,8 @@ public AzureStorageBlob(CloudBlob blob)
6777
ICloudBlob = blob;
6878
BlobType = blob.BlobType;
6979
Length = blob.Properties.Length;
80+
IsDeleted = blob.IsDeleted;
81+
RemainingDaysBeforePermanentDelete = blob.Properties.RemainingDaysBeforePermanentDelete;
7082
ContentType = blob.Properties.ContentType;
7183
LastModified = blob.Properties.LastModified;
7284
SnapshotTime = blob.SnapshotTime;

src/ResourceManager/Storage/Commands.Management.Storage/Commands.Management.Storage.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@
6767
<HintPath>..\..\..\packages\Microsoft.Data.Services.Client.5.8.2\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
6868
<Private>True</Private>
6969
</Reference>
70-
<Reference Include="Microsoft.WindowsAzure.Storage, Version=8.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
71-
<HintPath>..\..\..\packages\WindowsAzure.Storage.8.1.1\lib\net45\Microsoft.WindowsAzure.Storage.dll</HintPath>
70+
<Reference Include="Microsoft.WindowsAzure.Storage, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
71+
<HintPath>..\..\..\packages\WindowsAzure.Storage.9.0.0\lib\net45\Microsoft.WindowsAzure.Storage.dll</HintPath>
72+
</Reference>
73+
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
74+
<HintPath>..\..\..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
7275
<Private>True</Private>
7376
</Reference>
7477
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />

src/ResourceManager/Storage/Commands.Management.Storage/packages.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
<packages>
33
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
44
<package id="Microsoft.Azure.Management.Storage" version="7.1.0-preview" targetFramework="net452" />
5-
<package id="WindowsAzure.Storage" version="8.1.1" targetFramework="net452" />
5+
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" />
6+
<package id="WindowsAzure.Storage" version="9.0.0" targetFramework="net452" />
67
</packages>

src/Storage/Azure.Storage.psd1

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ CmdletsToExport = 'Get-AzureStorageTable', 'New-AzureStorageTableSASToken',
9898
'New-AzureStorageAccountSASToken', 'Set-AzureStorageCORSRule',
9999
'Get-AzureStorageCORSRule',
100100
'Get-AzureStorageServiceLoggingProperty',
101-
'Get-AzureStorageServiceMetricsProperty',
101+
'Get-AzureStorageServiceMetricsProperty',
102102
'Remove-AzureStorageCORSRule',
103103
'Set-AzureStorageServiceLoggingProperty',
104104
'Set-AzureStorageServiceMetricsProperty', 'New-AzureStorageContext',
@@ -116,14 +116,17 @@ CmdletsToExport = 'Get-AzureStorageTable', 'New-AzureStorageTableSASToken',
116116
'Start-AzureStorageBlobCopy',
117117
'Start-AzureStorageBlobIncrementalCopy',
118118
'Stop-AzureStorageBlobCopy', 'Update-AzureStorageServiceProperty',
119-
'Get-AzureStorageServiceProperty'
119+
'Get-AzureStorageServiceProperty',
120+
'Enable-AzureStorageDeleteRetentionPolicy',
121+
'Disable-AzureStorageDeleteRetentionPolicy'
120122

121123
# Variables to export from this module
122124
# VariablesToExport = @()
123125

124126
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
125127
AliasesToExport = 'Get-AzureStorageContainerAcl', 'Start-CopyAzureStorageBlob',
126-
'Stop-CopyAzureStorageBlob'
128+
'Stop-CopyAzureStorageBlob','Enable-AzureStorageSoftDelete',
129+
'Disable-AzureStorageSoftDelete'
127130

128131
# DSC resources to export from this module
129132
# DscResourcesToExport = @()

src/Storage/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
## Current Release
21+
* Support Soft-Delete feature
22+
- Enable-AzureStorageDeleteRetentionPolicy
23+
- Disable-AzureStorageDeleteRetentionPolicy
24+
- Get-AzureStorageBlob
2125

2226
## Version 4.1.1
2327
* Fix Get Blob Container cmdlet execute fail with Accout SAS credential issue

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@
122122
<Reference Include="Microsoft.WindowsAzure.Management">
123123
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
124124
</Reference>
125-
<Reference Include="Microsoft.WindowsAzure.Storage, Version=8.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
126-
<HintPath>..\..\packages\WindowsAzure.Storage.8.6.0\lib\net45\Microsoft.WindowsAzure.Storage.dll</HintPath>
125+
<Reference Include="Microsoft.WindowsAzure.Storage, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
126+
<HintPath>..\..\packages\WindowsAzure.Storage.9.0.0\lib\net45\Microsoft.WindowsAzure.Storage.dll</HintPath>
127127
</Reference>
128-
<Reference Include="Microsoft.WindowsAzure.Storage.DataMovement, Version=0.6.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
129-
<HintPath>..\..\packages\Microsoft.Azure.Storage.DataMovement.0.6.5\lib\net45\Microsoft.WindowsAzure.Storage.DataMovement.dll</HintPath>
128+
<Reference Include="Microsoft.WindowsAzure.Storage.DataMovement, Version=0.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
129+
<HintPath>..\..\packages\Microsoft.Azure.Storage.DataMovement.0.7.1\lib\net45\Microsoft.WindowsAzure.Storage.DataMovement.dll</HintPath>
130130
</Reference>
131-
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
132-
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
131+
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
132+
<HintPath>..\..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
133133
</Reference>
134134
<Reference Include="System" />
135135
<Reference Include="System.Data" />
@@ -280,6 +280,7 @@
280280
</ProjectReference>
281281
</ItemGroup>
282282
<ItemGroup>
283+
<None Include="app.config" />
283284
<None Include="MSSharedLibKey.snk" />
284285
<None Include="packages.config" />
285286
</ItemGroup>

src/Storage/Commands.Storage.Test/Common/PSServicePropertiesTest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ public void ValidateParseServicePropertiesTest()
6868
serviceProperties.Logging.LoggingOperations = LoggingOperations.All;
6969
serviceProperties.Logging.RetentionDays = 5;
7070
serviceProperties.DefaultServiceVersion = "2017-04-17";
71+
serviceProperties.DeleteRetentionPolicy = new DeleteRetentionPolicy();
72+
serviceProperties.DeleteRetentionPolicy.Enabled = true;
73+
serviceProperties.DeleteRetentionPolicy.RetentionDays = 5;
7174
PSSeriviceProperties pSSeriviceProperties = new PSSeriviceProperties(serviceProperties);
7275
CompareServiceProperties(pSSeriviceProperties, serviceProperties);
7376

@@ -111,6 +114,11 @@ static private void CompareServiceProperties(PSSeriviceProperties pSSeriviceProp
111114
{
112115
Assert.AreEqual(serviceProperties.DefaultServiceVersion, pSSeriviceProperties.DefaultServiceVersion);
113116
}
117+
if ((pSSeriviceProperties != null && pSSeriviceProperties.DeleteRetentionPolicy != null) || (serviceProperties != null && serviceProperties.DeleteRetentionPolicy != null))
118+
{
119+
Assert.AreEqual(serviceProperties.DeleteRetentionPolicy.Enabled, pSSeriviceProperties.DeleteRetentionPolicy.Enabled);
120+
Assert.AreEqual(serviceProperties.DeleteRetentionPolicy.RetentionDays, pSSeriviceProperties.DeleteRetentionPolicy.RetentionDays);
121+
}
114122
}
115123

116124
/// <summary>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<runtime>
4+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
5+
<dependentAssembly>
6+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
7+
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
8+
</dependentAssembly>
9+
</assemblyBinding>
10+
</runtime>
11+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup></configuration>

src/Storage/Commands.Storage.Test/packages.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
66
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
77
<package id="Microsoft.Azure.Management.Resources" version="2.18.11-preview" targetFramework="net45" />
8-
<package id="Microsoft.Azure.Storage.DataMovement" version="0.6.5" targetFramework="net452" />
8+
<package id="Microsoft.Azure.Storage.DataMovement" version="0.7.1" targetFramework="net452" />
99
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />
1010
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
1111
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
@@ -19,13 +19,13 @@
1919
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.2.9-preview" targetFramework="net45" />
2020
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.0" targetFramework="net45" />
2121
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
22-
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
22+
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" />
2323
<package id="System.ComponentModel.EventBasedAsync" version="4.0.11" targetFramework="net45" />
2424
<package id="System.Dynamic.Runtime" version="4.0.0" targetFramework="net45" />
2525
<package id="System.Linq.Queryable" version="4.0.0" targetFramework="net45" />
2626
<package id="System.Net.Requests" version="4.0.11" targetFramework="net45" />
2727
<package id="System.Spatial" version="5.8.2" targetFramework="net45" />
28-
<package id="WindowsAzure.Storage" version="8.6.0" targetFramework="net452" />
28+
<package id="WindowsAzure.Storage" version="9.0.0" targetFramework="net452" />
2929
<package id="xunit" version="2.1.0" targetFramework="net45" />
3030
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" />
3131
<package id="xunit.assert" version="2.1.0" targetFramework="net45" />

src/Storage/Commands.Storage/AzureStorageStartup.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ $script:aliases = @{
1717
"Get-AzureStorageContainerAcl" = "Get-AzureStorageContainer";
1818
"Start-CopyAzureStorageBlob" = "Start-AzureStorageBlobCopy";
1919
"Stop-CopyAzureStorageBlob" = "Stop-AzureStorageBlobCopy";
20+
"Enable-AzureStorageDeleteRetentionPolicy" = "Enable-AzureStorageSoftDelete";
21+
"Disable-AzureStorageDeleteRetentionPolicy" = "Disable-AzureStorageSoftDelete";
2022
}
2123

2224
$aliases.GetEnumerator() | Select @{Name='Name'; Expression={$_.Key}}, @{Name='Value'; Expression={$_.Value}} | New-Alias -Description "AzureAlias"

src/Storage/Commands.Storage/Blob/Cmdlet/GetAzureStorageBlob.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ public string Container
9191
}
9292

9393
private string containerName = String.Empty;
94+
95+
[Parameter(Mandatory = false, HelpMessage = "Include deleted blobs, by default get blob won't include deleted blobs")]
96+
[ValidateNotNullOrEmpty]
97+
public SwitchParameter IncludeDeleted { get; set; }
9498

9599
[Parameter(Mandatory = false, HelpMessage = "The max count of the blobs that can return.")]
96100
public int? MaxCount
@@ -161,15 +165,15 @@ internal async Task<CloudBlobContainer> GetCloudBlobContainerByName(IStorageBlob
161165
/// <param name="containerName">container name</param>
162166
/// <param name="blobName">blob name pattern</param>
163167
/// <returns>An enumerable collection of IListBlobItem</returns>
164-
internal async Task ListBlobsByName(long taskId, IStorageBlobManagement localChannel, string containerName, string blobName)
168+
internal async Task ListBlobsByName(long taskId, IStorageBlobManagement localChannel, string containerName, string blobName, bool includeDeleted = false)
165169
{
166170
CloudBlobContainer container = null;
167171
BlobRequestOptions requestOptions = RequestOptions;
168172
AccessCondition accessCondition = null;
169173

170174
string prefix = string.Empty;
171175

172-
if (String.IsNullOrEmpty(blobName) || WildcardPattern.ContainsWildcardCharacters(blobName))
176+
if (String.IsNullOrEmpty(blobName) || WildcardPattern.ContainsWildcardCharacters(blobName) || includeDeleted)
173177
{
174178
container = await GetCloudBlobContainerByName(localChannel, containerName).ConfigureAwait(false);
175179
prefix = NameUtil.GetNonWildcardPrefix(blobName);
@@ -182,7 +186,7 @@ internal async Task ListBlobsByName(long taskId, IStorageBlobManagement localCha
182186
}
183187

184188
Func<CloudBlob, bool> blobFilter = (blob) => wildcard == null || wildcard.IsMatch(blob.Name);
185-
await ListBlobsByPrefix(taskId, localChannel, containerName, prefix, blobFilter).ConfigureAwait(false);
189+
await ListBlobsByPrefix(taskId, localChannel, containerName, prefix, blobFilter, includeDeleted).ConfigureAwait(false);
186190
}
187191
else
188192
{
@@ -212,13 +216,17 @@ internal async Task ListBlobsByName(long taskId, IStorageBlobManagement localCha
212216
/// <param name="containerName">container name</param>
213217
/// <param name="prefix">blob preifx</param>
214218
/// <returns>An enumerable collection of IListBlobItem</returns>
215-
internal async Task ListBlobsByPrefix(long taskId, IStorageBlobManagement localChannel, string containerName, string prefix, Func<CloudBlob, bool> blobFilter = null)
219+
internal async Task ListBlobsByPrefix(long taskId, IStorageBlobManagement localChannel, string containerName, string prefix, Func<CloudBlob, bool> blobFilter = null, bool includeDeleted = false)
216220
{
217221
CloudBlobContainer container = await GetCloudBlobContainerByName(localChannel, containerName).ConfigureAwait(false);
218222

219223
BlobRequestOptions requestOptions = RequestOptions;
220224
bool useFlatBlobListing = true;
221225
BlobListingDetails details = BlobListingDetails.Snapshots | BlobListingDetails.Metadata | BlobListingDetails.Copy;
226+
if (includeDeleted)
227+
{
228+
details = details | BlobListingDetails.Deleted;
229+
}
222230

223231
int listCount = InternalMaxCount;
224232
int MaxListCount = 5000;
@@ -272,13 +280,13 @@ public override void ExecuteCmdlet()
272280
{
273281
string localContainerName = containerName;
274282
string localPrefix = blobPrefix;
275-
taskGenerator = (taskId) => ListBlobsByPrefix(taskId, localChannel, localContainerName, localPrefix);
283+
taskGenerator = (taskId) => ListBlobsByPrefix(taskId, localChannel, localContainerName, localPrefix, includeDeleted: IncludeDeleted.IsPresent);
276284
}
277285
else
278286
{
279287
string localContainerName = containerName;
280288
string localBlobName = blobName;
281-
taskGenerator = (taskId) => ListBlobsByName(taskId, localChannel, localContainerName, localBlobName);
289+
taskGenerator = (taskId) => ListBlobsByName(taskId, localChannel, localContainerName, localBlobName, includeDeleted: IncludeDeleted.IsPresent);
282290
}
283291

284292
RunTask(taskGenerator);

src/Storage/Commands.Storage/Commands.Storage.csproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@
6060
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6161
<HintPath>..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.1.8.0.0\lib\net35-full\Microsoft.WindowsAzure.Configuration.dll</HintPath>
6262
</Reference>
63-
<Reference Include="Microsoft.WindowsAzure.Storage, Version=8.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
64-
<HintPath>..\..\packages\WindowsAzure.Storage.8.6.0\lib\net45\Microsoft.WindowsAzure.Storage.dll</HintPath>
63+
<Reference Include="Microsoft.WindowsAzure.Storage, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
64+
<HintPath>..\..\packages\WindowsAzure.Storage.9.0.0\lib\net45\Microsoft.WindowsAzure.Storage.dll</HintPath>
6565
</Reference>
66-
<Reference Include="Microsoft.WindowsAzure.Storage.DataMovement, Version=0.6.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67-
<HintPath>..\..\packages\Microsoft.Azure.Storage.DataMovement.0.6.5\lib\net45\Microsoft.WindowsAzure.Storage.DataMovement.dll</HintPath>
66+
<Reference Include="Microsoft.WindowsAzure.Storage.DataMovement, Version=0.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67+
<HintPath>..\..\packages\Microsoft.Azure.Storage.DataMovement.0.7.1\lib\net45\Microsoft.WindowsAzure.Storage.DataMovement.dll</HintPath>
68+
</Reference>
69+
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
70+
<HintPath>..\..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
71+
<Private>True</Private>
6872
</Reference>
6973
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7074
<SpecificVersion>False</SpecificVersion>
@@ -121,6 +125,7 @@
121125
<Compile Include="Blob\Cmdlet\StartAzureStorageBlobCopy.cs" />
122126
<Compile Include="Blob\Cmdlet\StopAzureStorageBlobCopy.cs" />
123127
<Compile Include="Common\Cmdlet\GetAzureStorageServiceProperties.cs" />
128+
<Compile Include="Common\Cmdlet\DisableAzureStorageDeleteRetentionPolicy.cs" />
124129
<Compile Include="Common\Cmdlet\NewAzureStorageAccountSasToken.cs" />
125130
<Compile Include="Common\Cmdlet\SetAzureStorageCORSRule.cs" />
126131
<Compile Include="Common\Cmdlet\GetAzureStorageCORSRule.cs" />
@@ -129,6 +134,7 @@
129134
<Compile Include="Common\Cmdlet\RemoveAzureStorageCORSRule.cs" />
130135
<Compile Include="Common\Cmdlet\SetAzureStorageServiceProperties.cs" />
131136
<Compile Include="Common\Cmdlet\SetAzureStorageServiceLogging.cs" />
137+
<Compile Include="Common\Cmdlet\EnableAzureStorageDeleteRetentionPolicy.cs" />
132138
<Compile Include="Common\Cmdlet\SetAzureStorageServiceMetrics.cs" />
133139
<Compile Include="Common\ConfirmTaskCompletionSource.cs" />
134140
<Compile Include="Common\DataManagementWrapper.cs" />

0 commit comments

Comments
 (0)