Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'dev' into commonbvt

  • Loading branch information...
commit ff33ff94b13fbaf69066926708c614d8bb73b683 2 parents d6c7c9d + 2218e57
@xmbms xmbms authored
Showing with 1,160 additions and 666 deletions.
  1. +6 −0 ChangeLog.txt
  2. +3 −0  README.md
  3. +259 −0 WindowsAzurePowershell/src/Management.Storage.Test/Blob/Cmdlet/GetAzureStorageBlobTest.cs
  4. +229 −0 WindowsAzurePowershell/src/Management.Storage.Test/Blob/Cmdlet/RemoveAzureStorageBlobTest.cs
  5. +3 −3 WindowsAzurePowershell/src/Management.Storage.Test/Blob/Cmdlet/RemoveAzureStorageContainerTest.cs
  6. +2 −0  WindowsAzurePowershell/src/Management.Storage.Test/Management.Storage.Test.csproj
  7. +258 −0 WindowsAzurePowershell/src/Management.Storage/Blob/Cmdlet/GetAzureStorageBlob.cs
  8. +299 −0 WindowsAzurePowershell/src/Management.Storage/Blob/Cmdlet/RemoveAzureStorageBlob.cs
  9. +11 −1 WindowsAzurePowershell/src/Management.Storage/Blob/Cmdlet/RemoveAzureStorageContainer.cs
  10. +4 −0 WindowsAzurePowershell/src/Management.Storage/Management.Storage.csproj
  11. +43 −0 WindowsAzurePowershell/src/Management.Storage/Model/ResourceModel/AzureStorageBlob.cs
  12. +27 −0 WindowsAzurePowershell/src/Management.Storage/Resources.Designer.cs
  13. +12 −0 WindowsAzurePowershell/src/Management.Storage/Resources.resx
  14. +1 −0  WindowsAzurePowershell/src/Management.WebSites.Test/UnitTests/Cmdlets/GetAzureWebsiteLocationTests.cs
  15. +2 −1  WindowsAzurePowershell/src/Management.WebSites/Services/WebEntities/WebSpace.cs
  16. +0 −168 WindowsAzurePowershell/src/ServiceManagement/Storage/Blob/Contract/IStorageBlobManagement.cs
  17. +0 −255 WindowsAzurePowershell/src/ServiceManagement/Storage/Blob/Contract/StorageBlobManagement.cs
  18. +0 −63 WindowsAzurePowershell/src/ServiceManagement/Storage/Blob/ResourceModel/AzureStorageContainer.cs
  19. +0 −37 WindowsAzurePowershell/src/ServiceManagement/Storage/Common/ResourceModel/AzureStorageBase.cs
  20. +0 −78 WindowsAzurePowershell/src/ServiceManagement/Storage/Common/ResourceModel/AzureStorageContext.cs
  21. +0 −59 WindowsAzurePowershell/src/ServiceManagement/Storage/Util/StorageExceptionUtil.cs
  22. +1 −1  build.proj
View
6 ChangeLog.txt
@@ -1,3 +1,9 @@
+2013.03.06 Version 0.6.11
+ * Windows Azure Store cmdlets
+ * Upgraded to the latest service management library and update service management version header to 2012-12-01
+ * Added Save-AzureVhd cmdlet
+ * Updated Add-AzureVMImage, Get-AzureVMImage and Set-AzureVMImage cmdlets to support new attributes in service management version header 2012-12-01
+
2013.02.11 Version 0.6.10
* Upgrade to use PowerShell 3.0
* Released source code for VM and Cloud Services cmdlets
View
3  README.md
@@ -42,6 +42,9 @@ For documentation on how to build and deploy applications to Windows Azure pleas
* Get/Create DNS settings of a deployment.
* VNet
* Manage virtual network config, connection and gateway.
+* Store
+ * View available Windows Azure Store Add-On plans.
+ * Purchase, view, upgrade and remove Windows Azure Store Add-On instances.
* Utility
* Test whether a name is avaiable. Currently support cloud service name, storage account name and service bus namespace name.
* Get the list of geo locations supported by Azure.
View
259 WindowsAzurePowershell/src/Management.Storage.Test/Blob/Cmdlet/GetAzureStorageBlobTest.cs
@@ -0,0 +1,259 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ---------------------------------------------------------------------------------
+
+namespace Microsoft.WindowsAzure.Management.Storage.Test.Blob.Cmdlet
+{
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+ using Microsoft.WindowsAzure.Management.Storage.Blob;
+ using Microsoft.WindowsAzure.Management.Storage.Blob.Cmdlet;
+ using Microsoft.WindowsAzure.Management.Storage.Common;
+ using Microsoft.WindowsAzure.Management.Storage.Model.ResourceModel;
+ using Microsoft.WindowsAzure.Management.Test.Tests.Utilities;
+ using Microsoft.WindowsAzure.Storage.Blob;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+
+ [TestClass]
+ public class GetAzureStorageBlobTest : StorageBlobTestBase
+ {
+ public GetAzureStorageBlobCommand command = null;
+
+ [TestInitialize]
+ public void InitCommand()
+ {
+ command = new GetAzureStorageBlobCommand(BlobMock)
+ {
+ CommandRuntime = new MockCommandRuntime()
+ };
+ }
+
+ [TestCleanup]
+ public void CleanCommand()
+ {
+ command = null;
+ }
+
+ [TestMethod]
+ public void GetCloudBlobContainerByNameWithInvalidNameTest()
+ {
+ string name = string.Empty;
+ AssertThrows<ArgumentException>(() => command.GetCloudBlobContainerByName(name),
+ String.Format(Resources.InvalidContainerName, name));
+
+ name = "a";
+ AssertThrows<ArgumentException>(() => command.GetCloudBlobContainerByName(name),
+ String.Format(Resources.InvalidContainerName, name));
+
+ name = "abcde*-";
+ AssertThrows<ArgumentException>(() => command.GetCloudBlobContainerByName(name),
+ String.Format(Resources.InvalidContainerName, name));
+ }
+
+ [TestMethod]
+ public void GetCloudBlobContainerByNameWithNoExistsContainerTest()
+ {
+ string name = "test";
+ AssertThrows<ArgumentException>(() => command.GetCloudBlobContainerByName(name),
+ String.Format(Resources.ContainerNotFound, name));
+ }
+
+ [TestMethod]
+ public void GetCloudBlobContainerByNameSuccessfullyTest()
+ {
+ AddTestContainers();
+
+ string name = "test";
+ CloudBlobContainer container = command.GetCloudBlobContainerByName(name);
+ Assert.AreEqual(name, container.Name);
+ }
+
+ [TestMethod]
+ public void ListBlobsByNameWithEmptyContainerTest()
+ {
+ AddTestContainers();
+
+ string containerName = "test";
+ string blobName = "";
+ List<IListBlobItem> blobList = command.ListBlobsByName(containerName, blobName).ToList();
+ Assert.AreEqual(0, blobList.Count);
+
+ containerName = "test";
+ blobName = "*";
+ blobList = command.ListBlobsByName(containerName, blobName).ToList();
+ Assert.AreEqual(0, blobList.Count);
+
+ containerName = "test";
+ blobName = "blob";
+ AssertThrows<ResourceNotFoundException>(()=> command.ListBlobsByName(containerName, blobName).ToList(),
+ String.Format(Resources.BlobNotFound, blobName, containerName));
+ }
+
+ [TestMethod]
+ public void ListBlobsByNameWithInvalidBlobNameTest()
+ {
+ AddTestContainers();
+ string containerName = "test";
+ string blobName = new String('a', 1025);
+ AssertThrows<ArgumentException>(() => command.ListBlobsByName(containerName, blobName).ToList(),
+ String.Format(Resources.InvalidBlobName, blobName));
+ }
+
+ [TestMethod]
+ public void ListBlobsByNameWithWildCardTest()
+ {
+ AddTestBlobs();
+
+ string containerName = "container1";
+ string blobName = "blob*";
+ List<IListBlobItem> blobList = command.ListBlobsByName(containerName, blobName).ToList();
+ Assert.AreEqual(1, blobList.Count);
+ Assert.AreEqual("blob0", ((ICloudBlob)blobList[0]).Name);
+
+ containerName = "container20";
+ blobName = "*1?";
+ blobList = command.ListBlobsByName(containerName, blobName).ToList();
+ Assert.AreEqual(10, blobList.Count);
+ ICloudBlob blob = (ICloudBlob)blobList[0];
+ Assert.IsTrue(blob.Name.StartsWith("blob1") && blob.Name.Length == "blob1".Length + 1);
+ }
+
+ [TestMethod]
+ public void ListBlobsByNameSuccessfullyTest()
+ {
+ AddTestBlobs();
+ string containerName = "container1";
+ string blobName = "blob0";
+ List<IListBlobItem> blobList = command.ListBlobsByName(containerName, blobName).ToList();
+ Assert.AreEqual(1, blobList.Count);
+ Assert.AreEqual("blob0", ((ICloudBlob)blobList[0]).Name);
+
+ containerName = "container20";
+ blobName = String.Empty;
+ blobList = command.ListBlobsByName(containerName, blobName).ToList();
+ Assert.AreEqual(20, blobList.Count);
+ }
+
+ [TestMethod]
+ public void ListBlobsByPrefixWithInvalidPrefixTest()
+ {
+ string containerName = string.Empty;
+ string prefix = string.Empty;
+ AssertThrows<ArgumentException>(() => command.ListBlobsByPrefix(containerName, prefix),
+ String.Format(Resources.InvalidContainerName, containerName));
+
+ containerName = "test";
+ AssertThrows<ArgumentException>(() => command.ListBlobsByPrefix(containerName, prefix),
+ String.Format(Resources.ContainerNotFound, containerName));
+ }
+
+ [TestMethod]
+ public void ListBlobsByPrefixWithEmptyContainerTest()
+ {
+ AddTestContainers();
+ string containerName = "test";
+ string prefix = "1";
+
+ List<IListBlobItem> blobList = command.ListBlobsByPrefix(containerName, prefix).ToList();
+ Assert.AreEqual(0, blobList.Count);
+ }
+
+ [TestMethod]
+ public void ListBlobsByPrefixSuccessfullyTest()
+ {
+ AddTestBlobs();
+
+ string containerName = "container0";
+ string prefix = "blob";
+ List<IListBlobItem> blobList = command.ListBlobsByPrefix(containerName, prefix).ToList();
+ Assert.AreEqual(0, blobList.Count);
+
+ containerName = "container1";
+ prefix = "blob";
+ blobList = command.ListBlobsByPrefix(containerName, prefix).ToList();
+ Assert.AreEqual(1, blobList.Count);
+ ICloudBlob blob = (ICloudBlob)blobList[0];
+ Assert.AreEqual("blob0", blob.Name);
+
+ containerName = "container1";
+ prefix = "blob0";
+ blobList = command.ListBlobsByPrefix(containerName, prefix).ToList();
+ Assert.AreEqual(1, blobList.Count);
+ blob = (ICloudBlob) blobList[0];
+ Assert.AreEqual("blob0", blob.Name);
+
+ containerName = "container1";
+ prefix = "blob01";
+ blobList = command.ListBlobsByPrefix(containerName, prefix).ToList();
+ Assert.AreEqual(0, blobList.Count);
+
+ ((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
+ containerName = "container20";
+ prefix = "blob1";
+ blobList = command.ListBlobsByPrefix(containerName, prefix).ToList();
+ Assert.AreEqual(11, blobList.Count);
+ blob = (ICloudBlob) blobList[0];
+ Assert.IsTrue(blob.Name.StartsWith("blob1"));
+ }
+
+ [TestMethod]
+ public void WriteBlobsWithContext()
+ {
+ List<ICloudBlob> blobList = null;
+ ((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
+ command.WriteBlobsWithContext(blobList);
+ Assert.AreEqual(0, ((MockCommandRuntime)command.CommandRuntime).OutputPipeline.Count);
+
+ blobList = new List<ICloudBlob>();
+ ((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
+ command.WriteBlobsWithContext(blobList);
+ Assert.AreEqual(0, ((MockCommandRuntime)command.CommandRuntime).OutputPipeline.Count);
+
+ AddTestBlobs();
+ blobList = BlobMock.ContainerBlobs["container20"];
+ ((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
+ command.WriteBlobsWithContext(blobList);
+ Assert.AreEqual(20, ((MockCommandRuntime)command.CommandRuntime).OutputPipeline.Count);
+ }
+
+ [TestMethod]
+ public void ExecuteCommandGetAzureBlob()
+ {
+ AddTestBlobs();
+
+ ((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
+ command.Container = "container1";
+ command.Blob = "blob*";
+ command.ExecuteCmdlet();
+ Assert.AreEqual(1, ((MockCommandRuntime)command.CommandRuntime).OutputPipeline.Count);
+ AzureStorageBlob blob = (AzureStorageBlob)((MockCommandRuntime)command.CommandRuntime).OutputPipeline.FirstOrDefault();
+ Assert.AreEqual("blob0", blob.Name);
+
+ ((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
+ command.Container = "container20";
+ command.Blob = "blob12";
+ command.ExecuteCmdlet();
+ Assert.AreEqual(1, ((MockCommandRuntime)command.CommandRuntime).OutputPipeline.Count);
+ blob = (AzureStorageBlob)((MockCommandRuntime)command.CommandRuntime).OutputPipeline.FirstOrDefault();
+ Assert.AreEqual("blob12", blob.Name);
+
+ ((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
+ command.Container = "container20";
+ command.Blob = "*";
+ command.ExecuteCmdlet();
+ Assert.AreEqual(20, ((MockCommandRuntime)command.CommandRuntime).OutputPipeline.Count);
+ }
+ }
+}
View
229 WindowsAzurePowershell/src/Management.Storage.Test/Blob/Cmdlet/RemoveAzureStorageBlobTest.cs
@@ -0,0 +1,229 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ---------------------------------------------------------------------------------
+
+namespace Microsoft.WindowsAzure.Management.Storage.Test.Blob.Cmdlet
+{
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+ using Microsoft.WindowsAzure.Management.Storage.Blob;
+ using Microsoft.WindowsAzure.Management.Storage.Common;
+ using Microsoft.WindowsAzure.Management.Test.Tests.Utilities;
+ using Microsoft.WindowsAzure.Storage.Blob;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+
+ [TestClass]
+ public class RemoveAzureStorageBlobTest : StorageBlobTestBase
+ {
+ public RemoveStorageAzureBlobCommand command = null;
+
+ [TestInitialize]
+ public void InitCommand()
+ {
+ command = new RemoveStorageAzureBlobCommand(BlobMock)
+ {
+ CommandRuntime = new MockCommandRuntime()
+ };
+ }
+
+ [TestCleanup]
+ public void CleanCommand()
+ {
+ command = null;
+ }
+
+ [TestMethod]
+ public void ValidatePipelineCloudBlobContainerTest()
+ {
+ CloudBlobContainer container = null;
+ AssertThrows<ArgumentException>(()=>command.ValidatePipelineCloudBlobContainer(container),
+ String.Format(Resources.ObjectCannotBeNull, typeof(CloudBlobContainer).Name));
+
+ string invalidUri = "http://127.0.0.1/account/t";
+ container = new CloudBlobContainer(new Uri(invalidUri));
+ AssertThrows<ArgumentException>(() => command.ValidatePipelineCloudBlobContainer(container),
+ String.Format(Resources.InvalidContainerName, "t"));
+ string testUri = "http://127.0.0.1/account/test";
+ container = new CloudBlobContainer(new Uri(testUri));
+ AssertThrows<ResourceNotFoundException>(() => command.ValidatePipelineCloudBlobContainer(container),
+ String.Format(Resources.ContainerNotFound, "test"));
+
+ AddTestContainers();
+ command.ValidatePipelineCloudBlobContainer(container);
+ string textUri = "http://127.0.0.1/account/text";
+ container = new CloudBlobContainer(new Uri(textUri));
+ command.ValidatePipelineCloudBlobContainer(container);
+ }
+
+ [TestMethod]
+ public void ValidatePipelineICloudBlobTest()
+ {
+ CloudBlockBlob blockBlob = null;
+ AssertThrows<ArgumentException>(() => command.ValidatePipelineICloudBlob(blockBlob),
+ String.Format(Resources.ObjectCannotBeNull, typeof(ICloudBlob).Name));
+ string blobUri = "http://127.0.0.1/account/test/";
+ blockBlob = new CloudBlockBlob(new Uri(blobUri));
+ AssertThrows<ArgumentException>(() => command.ValidatePipelineICloudBlob(blockBlob),
+ String.Format(Resources.InvalidBlobName, blockBlob.Name));
+
+ AddTestBlobs();
+ string container1Uri = "http://127.0.0.1/account/container1/blob";
+ blockBlob = new CloudBlockBlob(new Uri(container1Uri));
+ AssertThrows<ResourceNotFoundException>(() => command.ValidatePipelineICloudBlob(blockBlob),
+ String.Format(Resources.BlobNotFound, blockBlob.Name, blockBlob.Container.Name));
+ container1Uri = "http://127.0.0.1/account/container1/blob0";
+ blockBlob = new CloudBlockBlob(new Uri(container1Uri));
+ command.ValidatePipelineICloudBlob(blockBlob);
+ }
+
+ [TestMethod]
+ public void RemoveAzureBlobByICloudBlobWithInvliadICloudBlob()
+ {
+ CloudBlockBlob blockBlob = null;
+ AssertThrows<ArgumentException>(() => command.RemoveAzureBlob(blockBlob, false),
+ String.Format(Resources.ObjectCannotBeNull, typeof(ICloudBlob).Name));
+ }
+
+ [TestMethod]
+ public void RemoveAzureBlobByICloudBlobWithNoExistsContainer()
+ {
+ string blobUri = "http://127.0.0.1/account/test/blob";
+ CloudBlockBlob blockBlob = new CloudBlockBlob(new Uri(blobUri));
+ command.RemoveAzureBlob(blockBlob, true);
+ AssertThrows<ResourceNotFoundException>(() => command.RemoveAzureBlob(blockBlob, false),
+ String.Format(Resources.ContainerNotFound, blockBlob.Container.Name));
+ }
+
+ [TestMethod]
+ public void RemoveAzureBlobByICloudBlobWithNoExistsBlobTest()
+ {
+ AddTestContainers();
+ string blobUri = "http://127.0.0.1/account/test/blob";
+ CloudBlockBlob blockBlob = new CloudBlockBlob(new Uri(blobUri));
+ AssertThrows<ResourceNotFoundException>(() => command.RemoveAzureBlob(blockBlob, false),
+ String.Format(Resources.BlobNotFound, blockBlob.Name, blockBlob.Container.Name));
+ }
+
+ [TestMethod]
+ public void RemoveAzureBlobByICloudBlobSuccessfulyTest()
+ {
+ AddTestBlobs();
+ string blobUri = "http://127.0.0.1/account/container0/blob0";
+ CloudBlockBlob blockBlob = new CloudBlockBlob(new Uri(blobUri));
+ command.RemoveAzureBlob(blockBlob, true);
+ AssertThrows<ResourceNotFoundException>(() => command.RemoveAzureBlob(blockBlob, false),
+ String.Format(Resources.BlobNotFound, blockBlob.Name, blockBlob.Container.Name));
+ blobUri = "http://127.0.0.1/account/container1/blob0";
+ blockBlob = new CloudBlockBlob(new Uri(blobUri));
+ command.RemoveAzureBlob(blockBlob, true);
+
+ AddTestBlobs();
+ command.RemoveAzureBlob(blockBlob, false);
+ AssertThrows<ResourceNotFoundException>(() => command.RemoveAzureBlob(blockBlob, false),
+ String.Format(Resources.BlobNotFound, blockBlob.Name, blockBlob.Container.Name));
+ }
+
+ [TestMethod]
+ public void RemoveAzureBlobByCloudBlobContainerWithInvalidNameTest()
+ {
+ CloudBlobContainer container = null;
+ string blobName = string.Empty;
+
+ AssertThrows<ArgumentException>(() => command.RemoveAzureBlob(container, blobName),
+ String.Format(Resources.InvalidBlobName, blobName));
+
+ blobName = "a";
+ AssertThrows<ArgumentException>(() => command.RemoveAzureBlob(container, blobName),
+ String.Format(Resources.ObjectCannotBeNull, typeof(CloudBlobContainer).Name));
+
+ string containeruri = "http://127.0.0.1/account/t";
+ container = new CloudBlobContainer(new Uri(containeruri));
+ AssertThrows<ArgumentException>(() => command.RemoveAzureBlob(container, blobName),
+ String.Format(Resources.InvalidContainerName, container.Name));
+ }
+
+ [TestMethod]
+ public void RemoveAzureBlobByCloudBlobContainerWithNotExistsContianerTest()
+ {
+ string containeruri = "http://127.0.0.1/account/test";
+ string blobName = "blob";
+ CloudBlobContainer container = new CloudBlobContainer(new Uri(containeruri));
+ AssertThrows<ResourceNotFoundException>(() => command.RemoveAzureBlob(container, blobName),
+ String.Format(Resources.ContainerNotFound, container.Name));
+ }
+
+ [TestMethod]
+ public void RemoveAzureBlobByCloudBlobContainerWithNotExistsBlobTest()
+ {
+ AddTestContainers();
+ string containeruri = "http://127.0.0.1/account/test";
+ CloudBlobContainer container = new CloudBlobContainer(new Uri(containeruri));
+ string blobName = "test";
+ AssertThrows<ResourceNotFoundException>(() => command.RemoveAzureBlob(container, blobName),
+ String.Format(Resources.BlobNotFound, blobName, container.Name));
+ }
+
+ [TestMethod]
+ public void RemoveAzureBlobByCloudBlobContainerSuccessfullyTest()
+ {
+ AddTestBlobs();
+ string containeruri = "http://127.0.0.1/account/container1";
+ CloudBlobContainer container = new CloudBlobContainer(new Uri(containeruri));
+ string blobName = "blob0";
+ command.RemoveAzureBlob(container, blobName);
+ AssertThrows<ResourceNotFoundException>(() => command.RemoveAzureBlob(container, blobName),
+ String.Format(Resources.BlobNotFound, blobName, "container1"));
+ }
+
+ [TestMethod]
+ public void RemoveAzureBlobByNameWithInvalidNameTest()
+ {
+ string containerName = string.Empty;
+ string blobName = string.Empty;
+ AssertThrows<ArgumentException>(() => command.RemoveAzureBlob(containerName, blobName),
+ String.Format(Resources.InvalidBlobName, blobName));
+ blobName = "abcd";
+ AssertThrows<ArgumentException>(() => command.RemoveAzureBlob(containerName, blobName),
+ String.Format(Resources.InvalidContainerName, containerName));
+ }
+
+ [TestMethod]
+ public void RemoveAzureBlobByNameTest()
+ {
+ AddTestBlobs();
+ string containerName = "container1";
+ string blobName = "blob0";
+ command.RemoveAzureBlob(containerName, blobName);
+ AssertThrows<ResourceNotFoundException>(() => command.RemoveAzureBlob(containerName, blobName),
+ String.Format(Resources.BlobNotFound, blobName, containerName));
+ }
+
+ [TestMethod]
+ public void ExecuteCommandRemoveBlobTest()
+ {
+ AddTestBlobs();
+ string containerName = "container20";
+ string blobName = "blob0";
+ command.Container = containerName;
+ command.Blob = blobName;
+ command.ExecuteCmdlet();
+ string result = (string)((MockCommandRuntime)command.CommandRuntime).VerboseStream.FirstOrDefault();
+ Assert.AreEqual(String.Format(Resources.RemoveBlobSuccessfully, blobName, containerName), result);
+ AssertThrows<ResourceNotFoundException>(() => command.ExecuteCmdlet(),
+ String.Format(Resources.BlobNotFound, blobName, containerName));
+
+ }
+ }
+}
View
6 WindowsAzurePowershell/src/Management.Storage.Test/Blob/Cmdlet/RemoveAzureStorageContainerTest.cs
@@ -72,7 +72,7 @@ public void RemoveContainerCancelledTest()
string name = "test";
((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
command.RemoveAzureContainer(name);
- string result = (string)((MockCommandRuntime)command.CommandRuntime).OutputPipeline.FirstOrDefault();
+ string result = (string)((MockCommandRuntime)command.CommandRuntime).VerboseStream.FirstOrDefault();
Assert.AreEqual(String.Format(Resources.RemoveContainerCancelled, name), result);
}
@@ -86,7 +86,7 @@ public void RemoveContainerSuccessfullyTest()
((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
command.confirm = true;
command.RemoveAzureContainer(name);
- string result = (string)((MockCommandRuntime)command.CommandRuntime).OutputPipeline.FirstOrDefault();
+ string result = (string)((MockCommandRuntime)command.CommandRuntime).VerboseStream.FirstOrDefault();
Assert.AreEqual(String.Format(Resources.RemoveContainerSuccessfully, name), result);
((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
@@ -94,7 +94,7 @@ public void RemoveContainerSuccessfullyTest()
command.Force = true;
command.confirm = false;
command.RemoveAzureContainer(name);
- result = (string)((MockCommandRuntime)command.CommandRuntime).OutputPipeline.FirstOrDefault();
+ result = (string)((MockCommandRuntime)command.CommandRuntime).VerboseStream.FirstOrDefault();
Assert.AreEqual(String.Format(Resources.RemoveContainerSuccessfully, name), result);
}
View
2  WindowsAzurePowershell/src/Management.Storage.Test/Management.Storage.Test.csproj
@@ -85,8 +85,10 @@
</Otherwise>
</Choose>
<ItemGroup>
+ <Compile Include="Blob\Cmdlet\GetAzureStorageBlobTest.cs" />
<Compile Include="Blob\Cmdlet\GetAzureStorageContainerTest.cs" />
<Compile Include="Blob\Cmdlet\NewAzureStorageContainerTest.cs" />
+ <Compile Include="Blob\Cmdlet\RemoveAzureStorageBlobTest.cs" />
<Compile Include="Blob\Cmdlet\RemoveAzureStorageContainerTest.cs" />
<Compile Include="Blob\Cmdlet\SetAzureStorageContainerAclTest.cs" />
<Compile Include="Blob\FakeRemoveAzureContainerCommand.cs" />
View
258 WindowsAzurePowershell/src/Management.Storage/Blob/Cmdlet/GetAzureStorageBlob.cs
@@ -0,0 +1,258 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+namespace Microsoft.WindowsAzure.Management.Storage.Blob.Cmdlet
+{
+ using Microsoft.WindowsAzure.Management.Storage.Common;
+ using Microsoft.WindowsAzure.Management.Storage.Model.Contract;
+ using Microsoft.WindowsAzure.Management.Storage.Model.ResourceModel;
+ using Microsoft.WindowsAzure.Storage;
+ using Microsoft.WindowsAzure.Storage.Blob;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Management.Automation;
+ using System.Security.Permissions;
+ using System.Text;
+
+ /// <summary>
+ /// list azure blobs in specified azure container
+ /// </summary>
+ [Cmdlet(VerbsCommon.Get, StorageNouns.Blob, DefaultParameterSetName = NameParameterSet),
+ OutputType(typeof(AzureStorageBlob))]
+ public class GetAzureStorageBlobCommand : StorageCloudBlobCmdletBase
+ {
+ /// <summary>
+ /// default parameter set name
+ /// </summary>
+ private const string NameParameterSet = "BlobName";
+
+ /// <summary>
+ /// prefix parameter set name
+ /// </summary>
+ private const string PrefixParameterSet = "BlobPrefix";
+
+ [Parameter(Position = 0, HelpMessage = "Blob name", ParameterSetName = NameParameterSet)]
+ public string Blob
+ {
+ get
+ {
+ return blobName;
+ }
+ set
+ {
+ blobName = value;
+ }
+ }
+ private string blobName = String.Empty;
+
+ [Parameter(HelpMessage = "Blob Prefix", ParameterSetName = PrefixParameterSet)]
+ public string Prefix
+ {
+ get
+ {
+ return blobPrefix;
+ }
+ set
+ {
+ blobPrefix = value;
+ }
+ }
+ private string blobPrefix = String.Empty;
+
+ [Alias("N", "Name")]
+ [Parameter(Position = 1, Mandatory = true, HelpMessage = "Container name",
+ ValueFromPipelineByPropertyName = true)]
+ [ValidateNotNullOrEmpty]
+ public string Container
+ {
+ get
+ {
+ return containerName;
+ }
+ set
+ {
+ containerName = value;
+ }
+ }
+ private string containerName = String.Empty;
+
+ /// <summary>
+ /// Initializes a new instance of the GetAzureStorageBlobCommand class.
+ /// </summary>
+ public GetAzureStorageBlobCommand()
+ : this(null)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the GetAzureStorageBlobCommand class.
+ /// </summary>
+ /// <param name="channel">IStorageBlobManagement channel</param>
+ public GetAzureStorageBlobCommand(IStorageBlobManagement channel)
+ {
+ Channel = channel;
+ }
+
+ /// <summary>
+ /// get the CloudBlobContianer object by name if container exists
+ /// </summary>
+ /// <param name="containerName">container name</param>
+ /// <returns>return CloudBlobContianer object if specified container exists, otherwise throw an exception</returns>
+ internal CloudBlobContainer GetCloudBlobContainerByName(string containerName)
+ {
+ if (!NameUtil.IsValidContainerName(containerName))
+ {
+ throw new ArgumentException(String.Format(Resources.InvalidContainerName, containerName));
+ }
+
+ BlobRequestOptions requestOptions = null;
+ CloudBlobContainer container = Channel.GetContainerReference(containerName);
+
+ if (!Channel.DoesContainerExist(container, requestOptions, OperationContext))
+ {
+ throw new ArgumentException(String.Format(Resources.ContainerNotFound, containerName));
+ }
+
+ return container;
+ }
+
+ /// <summary>
+ /// list blobs by blob name and container name
+ /// </summary>
+ /// <param name="containerName">container name</param>
+ /// <param name="blobName">blob name pattern</param>
+ /// <returns>An enumerable collection of IListBlobItem</returns>
+ [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
+ internal IEnumerable<IListBlobItem> ListBlobsByName(string containerName, string blobName)
+ {
+ CloudBlobContainer container = GetCloudBlobContainerByName(containerName);
+ BlobRequestOptions requestOptions = null;
+ AccessCondition accessCondition = null;
+
+ bool useFlatBlobListing = true;
+ string prefix = string.Empty;
+ BlobListingDetails details = BlobListingDetails.Snapshots | BlobListingDetails.Metadata;
+
+ if (String.IsNullOrEmpty(blobName) || WildcardPattern.ContainsWildcardCharacters(blobName))
+ {
+ IEnumerable<IListBlobItem> blobs = Channel.ListBlobs(container, prefix, useFlatBlobListing, details, requestOptions, OperationContext);
+ WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled;
+ WildcardPattern wildcard = null;
+
+ if (!String.IsNullOrEmpty(blobName))
+ {
+ wildcard = new WildcardPattern(blobName, options);
+ }
+
+ foreach (IListBlobItem blobItem in blobs)
+ {
+ ICloudBlob blob = blobItem as ICloudBlob;
+
+ if (blob == null)
+ {
+ continue;
+ }
+
+ if (wildcard == null || wildcard.IsMatch(blob.Name))
+ {
+ yield return blob;
+ }
+ }
+ }
+ else
+ {
+ if (!NameUtil.IsValidBlobName(blobName))
+ {
+ throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName));
+ }
+
+ ICloudBlob blob = Channel.GetBlobReferenceFromServer(container, blobName, accessCondition, requestOptions, OperationContext);
+
+ if (null == blob)
+ {
+ throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, containerName));
+ }
+ else
+ {
+ yield return blob;
+ }
+ }
+ }
+
+ /// <summary>
+ /// list blobs by blob prefix and container name
+ /// </summary>
+ /// <param name="containerName">container name</param>
+ /// <param name="prefix">blob preifx</param>
+ /// <returns>An enumerable collection of IListBlobItem</returns>
+ [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
+ internal IEnumerable<IListBlobItem> ListBlobsByPrefix(string containerName, string prefix)
+ {
+ CloudBlobContainer container = GetCloudBlobContainerByName(containerName);
+
+ BlobRequestOptions requestOptions = null;
+ bool useFlatBlobListing = true;
+ BlobListingDetails details = BlobListingDetails.Snapshots | BlobListingDetails.Metadata;
+
+ return Channel.ListBlobs(container, prefix, useFlatBlobListing, details, requestOptions, OperationContext);
+ }
+
+ /// <summary>
+ /// write blobs with storage context
+ /// </summary>
+ /// <param name="blobList">An enumerable collection of IListBlobItem</param>
+ [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
+ internal void WriteBlobsWithContext(IEnumerable<IListBlobItem> blobList)
+ {
+ if (null == blobList)
+ {
+ return;
+ }
+
+ foreach (IListBlobItem blobItem in blobList)
+ {
+ ICloudBlob blob = blobItem as ICloudBlob;
+
+ if (blob == null)
+ {
+ continue;
+ }
+
+ AzureStorageBlob azureBlob = new AzureStorageBlob(blob);
+ WriteObjectWithStorageContext(azureBlob);
+ }
+ }
+
+ /// <summary>
+ /// execute command
+ /// </summary>
+ [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
+ public override void ExecuteCmdlet()
+ {
+ IEnumerable<IListBlobItem> blobList = null;
+
+ if (PrefixParameterSet == ParameterSetName)
+ {
+ blobList = ListBlobsByPrefix(containerName, blobPrefix);
+ }
+ else
+ {
+ blobList = ListBlobsByName(containerName, blobName);
+ }
+
+ WriteBlobsWithContext(blobList);
+ }
+ }
+}
View
299 WindowsAzurePowershell/src/Management.Storage/Blob/Cmdlet/RemoveAzureStorageBlob.cs
@@ -0,0 +1,299 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+namespace Microsoft.WindowsAzure.Management.Storage.Blob
+{
+ using Microsoft.WindowsAzure.Management.Storage.Common;
+ using Microsoft.WindowsAzure.Management.Storage.Model.Contract;
+ using Microsoft.WindowsAzure.Management.Storage.Model.ResourceModel;
+ using Microsoft.WindowsAzure.Storage;
+ using Microsoft.WindowsAzure.Storage.Blob;
+ using System;
+ using System.Collections.Generic;
+ using System.Management.Automation;
+ using System.Security.Permissions;
+
+ [Cmdlet(VerbsCommon.Remove, StorageNouns.Blob, DefaultParameterSetName = NameParameterSet),
+ OutputType(typeof(AzureStorageBlob))]
+ public class RemoveStorageAzureBlobCommand : StorageCloudBlobCmdletBase
+ {
+ /// <summary>
+ /// Blob Pipeline parameter set name
+ /// </summary>
+ private const string BlobPipelineParameterSet = "BlobPipeline";
+
+ /// <summary>
+ /// container pipeline paremeter set name
+ /// </summary>
+ private const string ContainerPipelineParmeterSet = "ContainerPipeline";
+
+ /// <summary>
+ /// blob name and container name parameter set
+ /// </summary>
+ private const string NameParameterSet = "NamePipeline";
+
+ [Parameter(HelpMessage = "ICloudBlob Object", Mandatory = true,
+ ValueFromPipelineByPropertyName = true, ParameterSetName = BlobPipelineParameterSet)]
+ public ICloudBlob ICloudBlob { get; set; }
+
+ [Parameter(HelpMessage = "CloudBlobContainer Object", Mandatory = true,
+ ValueFromPipelineByPropertyName = true, ParameterSetName = ContainerPipelineParmeterSet)]
+ public CloudBlobContainer CloudBlobContainer { get; set; }
+
+ [Parameter(ParameterSetName = ContainerPipelineParmeterSet, Mandatory = true, Position = 0, HelpMessage = "Blob name")]
+ [Parameter(ParameterSetName = NameParameterSet, Mandatory = true, Position = 0, HelpMessage = "Blob name")]
+ public string Blob
+ {
+ get { return BlobName; }
+ set { BlobName = value; }
+ }
+ private string BlobName = String.Empty;
+
+ [Parameter(HelpMessage = "Container name", Mandatory = true, Position = 1,
+ ParameterSetName = NameParameterSet)]
+ [ValidateNotNullOrEmpty]
+ public string Container
+ {
+ get { return ContainerName; }
+ set { ContainerName = value; }
+ }
+ private string ContainerName = String.Empty;
+
+ [Parameter(HelpMessage = "Delete the blob and its snapshots")]
+ public SwitchParameter DeleteSnapshot
+ {
+ get { return deleteSnapshot; }
+ set { deleteSnapshot = value; }
+ }
+ private bool deleteSnapshot;
+
+ [Parameter(HelpMessage = "Force to remove the blob and its snapshot without confirmation")]
+ public SwitchParameter Force
+ {
+ get { return force; }
+ set { force = value; }
+ }
+ private bool force = false;
+
+ [Parameter(Mandatory = false, HelpMessage = "Return whether the specifed blob is successfully removed")]
+ public SwitchParameter PassThru { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the RemoveStorageAzureBlobCommand class.
+ /// </summary>
+ public RemoveStorageAzureBlobCommand()
+ : this(null)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the RemoveStorageAzureBlobCommand class.
+ /// </summary>
+ /// <param name="channel">IStorageBlobManagement channel</param>
+ public RemoveStorageAzureBlobCommand(IStorageBlobManagement channel)
+ {
+ Channel = channel;
+ }
+
+ /// <summary>
+ /// confirm the remove operation
+ /// </summary>
+ /// <param name="message">confirmation message</param>
+ /// <returns>true if the operation is confirmed by user, otherwise false</returns>
+ [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
+ internal virtual bool ConfirmRemove(string message)
+ {
+ return ShouldProcess(message);
+ }
+
+ /// <summary>
+ /// whether the specified blob is a snapshot
+ /// </summary>
+ /// <param name="blob">ICloudBlob object</param>
+ /// <returns>true if the specified blob is snapshot, otherwise false</returns>
+ [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
+ internal bool IsSnapshot(ICloudBlob blob)
+ {
+ return !string.IsNullOrEmpty(blob.Name) && blob.SnapshotTime != null;
+ }
+
+ /// <summary>
+ /// check whether specified blob has snapshot
+ /// </summary>
+ /// <param name="blob">ICloudBlob object</param>
+ /// <returns>true if the specified blob has snapshot, otherwise false</returns>
+ [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
+ internal bool HasSnapShot(ICloudBlob blob)
+ {
+ BlobListingDetails details = BlobListingDetails.Snapshots;
+ BlobRequestOptions requestOptions = null;
+ bool useFlatBlobListing = true;
+
+ if (IsSnapshot(blob)) //snapshot can't have snapshot
+ {
+ return false;
+ }
+
+ IEnumerable<IListBlobItem> snapshots = Channel.ListBlobs(blob.Container, blob.Name, useFlatBlobListing, details, requestOptions, OperationContext);
+
+ foreach (IListBlobItem item in snapshots)
+ {
+ ICloudBlob blobItem = item as ICloudBlob;
+
+ if (blobItem != null && blobItem.Name == blob.Name && blobItem.SnapshotTime != null)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /// <summary>
+ /// remove the azure blob
+ /// </summary>
+ /// <param name="blob">ICloudblob object</param>
+ /// <param name="isValidBlob">whether the ICloudblob parameter is validated</param>
+ /// <returns>true if the blob is removed successfully, false if user cancel the remove operation</returns>
+ [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
+ internal bool RemoveAzureBlob(ICloudBlob blob, bool isValidBlob = false)
+ {
+ if (!isValidBlob)
+ {
+ ValidatePipelineICloudBlob(blob);
+ }
+
+ DeleteSnapshotsOption deleteSnapshotsOption = DeleteSnapshotsOption.None;
+ AccessCondition accessCondition = null;
+ BlobRequestOptions requestOptions = null;
+
+ if (IsSnapshot(blob) && deleteSnapshot)
+ {
+ throw new ArgumentException(String.Format(Resources.CannotDeleteSnapshotForSnapshot, blob.Name, blob.SnapshotTime));
+ }
+
+ if (deleteSnapshot)
+ {
+ deleteSnapshotsOption = DeleteSnapshotsOption.DeleteSnapshotsOnly;
+ }
+ else if (HasSnapShot(blob))
+ {
+ string message = string.Format(Resources.ConfirmRemoveBlobWithSnapshot, blob.Name, blob.Container.Name);
+
+ if (force || ConfirmRemove(message))
+ {
+ deleteSnapshotsOption = DeleteSnapshotsOption.IncludeSnapshots;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ Channel.DeleteICloudBlob(blob, deleteSnapshotsOption, accessCondition, requestOptions, OperationContext);
+ return true;
+ }
+
+ /// <summary>
+ /// remove azure blob
+ /// </summary>
+ /// <param name="container">CloudBlobContainer object</param>
+ /// <param name="blobName">blob name</param>
+ /// <returns>true if the blob is removed successfully, false if user cancel the remove operation</returns>
+ [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
+ internal bool RemoveAzureBlob(CloudBlobContainer container, string blobName)
+ {
+ if (!NameUtil.IsValidBlobName(blobName))
+ {
+ throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName));
+ }
+
+ ValidatePipelineCloudBlobContainer(container);
+ AccessCondition accessCondition = null;
+ BlobRequestOptions requestOptions = null;
+ ICloudBlob blob = Channel.GetBlobReferenceFromServer(container, blobName, accessCondition, requestOptions, OperationContext);
+
+ if (null == blob)
+ {
+ throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, container.Name));
+ }
+
+ return RemoveAzureBlob(blob, true);
+ }
+
+ /// <summary>
+ /// remove azure blob
+ /// </summary>
+ /// <param name="containerName">container name</param>
+ /// <param name="blobName">blob name</param>
+ /// <returns>true if the blob is removed successfully, false if user cancel the remove operation</returns>
+ [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
+ internal bool RemoveAzureBlob(string containerName, string blobName)
+ {
+ CloudBlobContainer container = Channel.GetContainerReference(containerName);
+ return RemoveAzureBlob(container, blobName);
+ }
+
+ /// <summary>
+ /// execute command
+ /// </summary>
+ [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
+ public override void ExecuteCmdlet()
+ {
+ string blobName = string.Empty;
+ string containerName = string.Empty;
+ bool removed = false;
+
+ switch (ParameterSetName)
+ {
+ case BlobPipelineParameterSet:
+ removed = RemoveAzureBlob(ICloudBlob, false);
+ blobName = ICloudBlob.Name;
+ containerName = ICloudBlob.Container.Name;
+ break;
+
+ case ContainerPipelineParmeterSet:
+ removed = RemoveAzureBlob(CloudBlobContainer, BlobName);
+ blobName = BlobName;
+ containerName = ContainerName;
+ break;
+
+ case NameParameterSet:
+ default:
+ removed = RemoveAzureBlob(ContainerName, BlobName);
+ blobName = BlobName;
+ containerName = ContainerName;
+ break;
+ }
+
+ string result = string.Empty;
+
+ if (removed)
+ {
+ result = String.Format(Resources.RemoveBlobSuccessfully, blobName, containerName);
+ }
+ else
+ {
+ result = String.Format(Resources.RemoveBlobCancelled, blobName, containerName);
+ }
+
+ WriteVerbose(result);
+
+ if (PassThru)
+ {
+ WriteObject(removed);
+ }
+ }
+ }
+}
View
12 WindowsAzurePowershell/src/Management.Storage/Blob/Cmdlet/RemoveAzureStorageContainer.cs
@@ -48,6 +48,9 @@ public SwitchParameter Force
}
private bool force;
+ [Parameter(Mandatory = false, HelpMessage = "Return whether the specifed blob is successfully removed")]
+ public SwitchParameter PassThru { get; set; }
+
/// <summary>
/// Initializes a new instance of the RemoveAzureStorageContainerCommand class.
/// </summary>
@@ -99,18 +102,25 @@ internal void RemoveAzureContainer(string name)
}
string result = string.Empty;
+ bool removed = false;
if (force || ConfirmRemove(name))
{
Channel.DeleteContainer(container, accessCondition, requestOptions, OperationContext);
result = String.Format(Resources.RemoveContainerSuccessfully, name);
+ removed = true;
}
else
{
result = String.Format(Resources.RemoveContainerCancelled, name);
}
- WriteObject(result);
+ WriteVerbose(result);
+
+ if (PassThru)
+ {
+ WriteObject(removed);
+ }
}
/// <summary>
View
4 WindowsAzurePowershell/src/Management.Storage/Management.Storage.csproj
@@ -85,8 +85,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Blob\Cmdlet\GetAzureStorageBlob.cs" />
<Compile Include="Blob\Cmdlet\GetAzureStorageContainer.cs" />
<Compile Include="Blob\Cmdlet\NewAzureStorageContainer.cs" />
+ <Compile Include="Blob\Cmdlet\RemoveAzureStorageBlob.cs" />
<Compile Include="Blob\Cmdlet\RemoveAzureStorageContainer.cs" />
<Compile Include="Blob\Cmdlet\SetAzureStorageContainerAcl.cs" />
<Compile Include="Common\CmdletOperationContext.cs" />
@@ -99,6 +101,7 @@
<Compile Include="Blob\StorageCloudBlobCmdletBase.cs" />
<Compile Include="Common\StorageExceptionUtil.cs" />
<Compile Include="Common\StorageNouns.cs" />
+ <Compile Include="Model\ResourceModel\AzureStorageBlob.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Model\Contract\IStorageBlobManagement.cs" />
<Compile Include="Model\Contract\StorageBlobManagement.cs" />
@@ -131,6 +134,7 @@
<Generator>ResXFileCodeGenerator</Generator>
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
View
43 WindowsAzurePowershell/src/Management.Storage/Model/ResourceModel/AzureStorageBlob.cs
@@ -0,0 +1,43 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ---------------------------------------------------------------------------------
+
+namespace Microsoft.WindowsAzure.Management.Storage.Model.ResourceModel
+{
+ using Microsoft.WindowsAzure.Storage.Blob;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+
+ public class AzureStorageBlob : AzureStorageBase
+ {
+ public ICloudBlob ICloudBlob { get; private set; }
+ public BlobType BlobType { get; private set; }
+ public long Length { get; private set; }
+ public string ContentType { get; private set; }
+ public DateTimeOffset? LastModified { get; private set; }
+ public DateTimeOffset? SnapshotTime { get; private set; }
+
+ public AzureStorageBlob(ICloudBlob blob)
+ {
+ Name = blob.Name;
+ ICloudBlob = blob;
+ BlobType = blob.BlobType;
+ Length = blob.Properties.Length;
+ ContentType = blob.Properties.ContentType;
+ LastModified = blob.Properties.LastModified;
+ SnapshotTime = blob.SnapshotTime;
+ }
+ }
+}
View
27 WindowsAzurePowershell/src/Management.Storage/Resources.Designer.cs
@@ -133,6 +133,15 @@ internal class Resources {
}
/// <summary>
+ /// Looks up a localized string similar to The specified blob &apos;{0}&apos; is already a snapshot with snapshot time {1}. Can&apos;t use &quot;DeleteSnapshot&quot; option for it..
+ /// </summary>
+ internal static string CannotDeleteSnapshotForSnapshot {
+ get {
+ return ResourceManager.GetString("CannotDeleteSnapshotForSnapshot", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Can not get storage account from subscription. Please check the subscription settings using &quot;Get-AzureSubscription&quot;..
/// </summary>
internal static string CannotGetSotrageAccountFromSubscription {
@@ -169,6 +178,15 @@ internal class Resources {
}
/// <summary>
+ /// Looks up a localized string similar to The blob &apos;{0}&apos; in container &apos;{1}&apos; has snapshots. Are you sure to remove blob and its snapshots?.
+ /// </summary>
+ internal static string ConfirmRemoveBlobWithSnapshot {
+ get {
+ return ResourceManager.GetString("ConfirmRemoveBlobWithSnapshot", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Are you sure to remove container &apos;{0}&apos;?.
/// </summary>
internal static string ConfirmRemoveContainer {
@@ -574,6 +592,15 @@ internal class Resources {
}
/// <summary>
+ /// Looks up a localized string similar to The remove operation of blob &apos;{0}&apos; in container &apos;{1}&apos; is cancelled..
+ /// </summary>
+ internal static string RemoveBlobCancelled {
+ get {
+ return ResourceManager.GetString("RemoveBlobCancelled", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Removed blob &apos;{0}&apos; in container &apos;{1}&apos; successfully..
/// </summary>
internal static string RemoveBlobSuccessfully {
View
12 WindowsAzurePowershell/src/Management.Storage/Resources.resx
@@ -346,6 +346,18 @@
<data name="BeginProcessingWithParameterSetLog" xml:space="preserve">
<value>{0} begin processing with ParameterSet '{1}'.</value>
</data>
+ <data name="CannotDeleteSnapshotForSnapshot" xml:space="preserve">
+ <value>The specified blob '{0}' is already a snapshot with snapshot time {1}. Can't use "DeleteSnapshot" option for it.</value>
+ <comment>0 for blob name, 1 for snapshot time </comment>
+ </data>
+ <data name="ConfirmRemoveBlobWithSnapshot" xml:space="preserve">
+ <value>The blob '{0}' in container '{1}' has snapshots. Are you sure to remove blob and its snapshots?</value>
+ <comment>0 for blob name, 1 for container name</comment>
+ </data>
+ <data name="RemoveBlobCancelled" xml:space="preserve">
+ <value>The remove operation of blob '{0}' in container '{1}' is cancelled.</value>
+ <comment>0 for blob name, 1 for container name</comment>
+ </data>
<data name="GetAzureStorageContainerAclCmdletName" xml:space="preserve">
<value>Get-AzureStorageContainerAcl</value>
</data>
View
1  WindowsAzurePowershell/src/Management.WebSites.Test/UnitTests/Cmdlets/GetAzureWebsiteLocationTests.cs
@@ -48,6 +48,7 @@ public void ProcessGetAzureWebsiteLocationTest()
Assert.IsTrue(locations.Any(loc => loc.Equals("West US")));
Assert.IsTrue(locations.Any(loc => loc.Equals("North Europe")));
Assert.IsTrue(locations.Any(loc => loc.Equals("West Europe")));
+ Assert.IsTrue(locations.Any(loc => loc.Equals("East Asia")));
}
}
}
View
3  WindowsAzurePowershell/src/Management.WebSites/Services/WebEntities/WebSpace.cs
@@ -24,7 +24,8 @@ public static class AvailableWebspaces
{ "North Europe", "northeuropewebspace" },
{ "West Europe", "westeuropewebspace" },
{ "East US", "eastuswebspace" },
- { "West US", "westuswebspace" } };
+ { "West US", "westuswebspace" },
+ { "East Asia", "eastasiawebspace" }};
}
[DataContract(Name = "Status", Namespace = UriElements.ServiceNamespace)]
View
168 WindowsAzurePowershell/src/ServiceManagement/Storage/Blob/Contract/IStorageBlobManagement.cs
@@ -1,168 +0,0 @@
-// ----------------------------------------------------------------------------------
-//
-// Copyright Microsoft Corporation
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// ----------------------------------------------------------------------------------
-
-namespace Microsoft.WindowsAzure.ServiceManagement.Storage.Blob.Contract
-{
- using Microsoft.WindowsAzure.Storage;
- using Microsoft.WindowsAzure.Storage.Blob;
- using System;
- using System.Collections.Generic;
-
- /// <summary>
- /// Blob management interface
- /// </summary>
- public interface IStorageBlobManagement
- {
- /// <summary>
- /// Get a list of cloudblobcontainer in azure
- /// </summary>
- /// <param name="prefix">Container prefix</param>
- /// <param name="detailsIncluded">Container listing details</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>An enumerable collection of cloudblobcontainer</returns>
- IEnumerable<CloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded, BlobRequestOptions options, OperationContext OperationContext);
-
- /// <summary>
- /// Get container presssions
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>The container's permission</returns>
- BlobContainerPermissions GetContainerPermissions(CloudBlobContainer container, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext);
-
- /// <summary>
- /// Set container permissions
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="permissions">The container's permission</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- void SetContainerPermissions(CloudBlobContainer container, BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext);
-
- /// <summary>
- /// Get an CloudBlobContainer instance in local
- /// </summary>
- /// <param name="name">Container name</param>
- /// <returns>A CloudBlobContainer in local memory</returns>
- CloudBlobContainer GetContainerReference(String name);
-
- /// <summary>
- /// Get blob reference with properties and meta data from server
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="blobName">Blob name</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">Blob request options</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>Return an ICloudBlob if the specific blob exists on azure, otherwise return null</returns>
- ICloudBlob GetBlobReferenceFromServer(CloudBlobContainer container, string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext);
-
- /// <summary>
- /// Whether the container is exists or not
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>True if the specific container exists, otherwise return false</returns>
- bool DoesContainerExist(CloudBlobContainer container, BlobRequestOptions options, OperationContext OperationContext);
-
- /// <summary>
- /// Whether the blob is exists or not
- /// </summary>
- /// <param name="blob">A icloudblob object</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>True if the specific blob exists, otherwise return false</returns>
- bool DoesBlobExist(ICloudBlob blob, BlobRequestOptions options, OperationContext OperationContext);
-
- /// <summary>
- /// Create the container if not exists
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>True if the container did not already exist and was created; otherwise false.</returns>
- bool CreateContainerIfNotExists(CloudBlobContainer container, BlobRequestOptions requestOptions, OperationContext OperationContext);
-
- /// <summary>
- /// Delete container
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- void DeleteContainer(CloudBlobContainer container, AccessCondition accessCondition, BlobRequestOptions options, OperationContext OperationContext);
-
- /// <summary>
- /// List all blobs in specified containers
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="prefix">Blob prefix</param>
- /// <param name="useFlatBlobListing">Use flat blob listing(whether treat "container/" as directory)</param>
- /// <param name="blobListingDetails">Blob listing details</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>An enumerable collection of icloudblob</returns>
- IEnumerable<IListBlobItem> ListBlobs(CloudBlobContainer container, string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, BlobRequestOptions options, OperationContext operationContext);
-
- /// <summary>
- /// Delete azure blob
- /// </summary>
- /// <param name="blob">ICloudblob object</param>
- /// <param name="deleteSnapshotsOption">Delete snapshots option</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>An enumerable collection of icloudblob</returns>
- void DeleteICloudBlob(ICloudBlob blob, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext);
-
- /// <summary>
- /// fetch container attributes
- /// </summary>
- /// <param name="container">CloudBlobContainer object</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">blob request options</param>
- /// <param name="operationContext">An object that represents the context for the current operation.</param>
- void FetchContainerAttributes(CloudBlobContainer container, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext);
-
- /// <summary>
- /// fetch blob attributes
- /// </summary>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">blob request options</param>
- /// <param name="operationContext">An object that represents the context for the current operation.</param>
- void FetchBlobAttributes(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext);
-
- /// <summary>
- /// set blob properties
- /// </summary>
- /// <param name="blob">ICloud blob object</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">blob request options</param>
- /// <param name="operationContext">An object that represents the context for the current operation.</param>
- void SetBlobProperties(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext);
-
- /// <summary>
- /// set blob meta data
- /// </summary>
- /// <param name="blob">ICloud blob object</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">blob request options</param>
- /// <param name="operationContext">An object that represents the context for the current operation.</param>
- void SetBlobMetadata(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext);
- }
-}
View
255 WindowsAzurePowershell/src/ServiceManagement/Storage/Blob/Contract/StorageBlobManagement.cs
@@ -1,255 +0,0 @@
-// ----------------------------------------------------------------------------------
-//
-// Copyright Microsoft Corporation
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// ----------------------------------------------------------------------------------
-
-namespace Microsoft.WindowsAzure.ServiceManagement.Storage.Blob.Contract
-{
- using Microsoft.WindowsAzure.ServiceManagement.Storage.Util;
- using Microsoft.WindowsAzure.Storage;
- using Microsoft.WindowsAzure.Storage.Blob;
- using System.Collections.Generic;
-
- /// <summary>
- /// Blob management
- /// </summary>
- public class StorageBlobManagement : IStorageBlobManagement
- {
- /// <summary>
- /// Azure storage blob client
- /// </summary>
- private CloudBlobClient blobClient;
-
- /// <summary>
- /// Init blob management
- /// </summary>
- /// <param name="client">a cloud blob object</param>
- public StorageBlobManagement(CloudBlobClient client)
- {
- blobClient = client;
- }
-
- /// <summary>
- /// Get a list of cloudblobcontainer in azure
- /// </summary>
- /// <param name="prefix">Container prefix</param>
- /// <param name="detailsIncluded">Container listing details</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>An enumerable collection of cloudblobcontainer</returns>
- public IEnumerable<CloudBlobContainer> ListContainers(string prefix, ContainerListingDetails detailsIncluded, BlobRequestOptions options, OperationContext operationContext)
- {
- return blobClient.ListContainers(prefix, detailsIncluded, options, operationContext);
- }
-
- /// <summary>
- /// Get container presssions
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>The container's permission</returns>
- public BlobContainerPermissions GetContainerPermissions(CloudBlobContainer container, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- {
- return container.GetPermissions(accessCondition, options, operationContext);
- }
-
- /// <summary>
- /// Get an CloudBlobContainer instance in local
- /// </summary>
- /// <param name="name">Container name</param>
- /// <returns>A CloudBlobContainer in local memory</returns>
- public CloudBlobContainer GetContainerReference(string name)
- {
- return blobClient.GetContainerReference(name);
- }
-
- /// <summary>
- /// Create the container if not exists
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>True if the container did not already exist and was created; otherwise false.</returns>
- public bool CreateContainerIfNotExists(CloudBlobContainer container, BlobRequestOptions requestOptions, OperationContext operationContext)
- {
- return container.CreateIfNotExists(requestOptions, operationContext);
- }
-
- /// <summary>
- /// Delete container
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- public void DeleteContainer(CloudBlobContainer container, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- {
- container.Delete(accessCondition, options, operationContext);
- }
-
- /// <summary>
- /// Set container permissions
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="permissions">The container's permission</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- public void SetContainerPermissions(CloudBlobContainer container, BlobContainerPermissions permissions, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- {
- container.SetPermissions(permissions, accessCondition, options, operationContext);
- }
-
- /// <summary>
- /// Get blob reference with properties and meta data from server
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="blobName">Blob name</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">Blob request options</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>Return an ICloudBlob if the specific blob exists on azure, otherwise return null</returns>
- public ICloudBlob GetBlobReferenceFromServer(CloudBlobContainer container, string blobName, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- {
- try
- {
- ICloudBlob blob = container.GetBlobReferenceFromServer(blobName, accessCondition, options, operationContext);
- return blob;
- }
- catch(StorageException e)
- {
- if (e.IsNotFoundException())
- {
- return null;
- }
- else
- {
- throw;
- }
- }
- }
-
- /// <summary>
- /// List all blobs in specified containers
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="prefix">Blob prefix</param>
- /// <param name="useFlatBlobListing">Use flat blob listing(whether treat "container/" as directory)</param>
- /// <param name="blobListingDetails">Blob listing details</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>An enumerable collection of icloudblob</returns>
- public IEnumerable<IListBlobItem> ListBlobs(CloudBlobContainer container, string prefix, bool useFlatBlobListing, BlobListingDetails blobListingDetails, BlobRequestOptions options, OperationContext operationContext)
- {
- return container.ListBlobs(prefix, useFlatBlobListing, blobListingDetails, options, operationContext);
- }
-
- /// <summary>
- /// Whether the container exists or not
- /// </summary>
- /// <param name="container">A cloudblobcontainer object</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>True if the specific container exists, otherwise return false</returns>
- public bool DoesContainerExist(CloudBlobContainer container, BlobRequestOptions options, OperationContext operationContext)
- {
- if (null == container)
- {
- return false;
- }
- else
- {
- return container.Exists(options, operationContext);
- }
- }
-
- /// <summary>
- /// Whether the blob is exists or not
- /// </summary>
- /// <param name="blob">An ICloudBlob object</param>
- /// <param name="options">Blob request option</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>True if the specific blob exists, otherwise return false</returns>
- public bool DoesBlobExist(ICloudBlob blob, BlobRequestOptions options, OperationContext operationContext)
- {
- if (null == blob)
- {
- return false;
- }
- else
- {
- return blob.Exists(options, operationContext);
- }
- }
-
- /// <summary>
- /// Delete azure blob
- /// </summary>
- /// <param name="blob">ICloudblob object</param>
- /// <param name="deleteSnapshotsOption">Delete snapshots option</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="operationContext">Operation context</param>
- /// <returns>An enumerable collection of icloudblob</returns>
- public void DeleteICloudBlob(ICloudBlob blob, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- {
- blob.Delete(deleteSnapshotsOption, accessCondition, options, operationContext);
- }
-
- /// <summary>
- /// fetch container attributes
- /// </summary>
- /// <param name="container">CloudBlobContainer object</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">blob request options</param>
- /// <param name="operationContext">An object that represents the context for the current operation.</param>
- public void FetchContainerAttributes(CloudBlobContainer container, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- {
- container.FetchAttributes(accessCondition, options, operationContext);
- }
-
- /// <summary>
- /// fetch blob attributes
- /// </summary>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">blob request options</param>
- /// <param name="operationContext">An object that represents the context for the current operation.</param>
- public void FetchBlobAttributes(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- {
- blob.FetchAttributes(accessCondition, options, operationContext);
- }
-
- /// <summary>
- /// set blob properties
- /// </summary>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">blob request options</param>
- /// <param name="operationContext">An object that represents the context for the current operation.</param>
- public void SetBlobProperties(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- {
- blob.SetProperties(accessCondition, options, operationContext);
- }
-
- /// <summary>
- /// set blob meta data
- /// </summary>
- /// <param name="blob">ICloud blob object</param>
- /// <param name="accessCondition">Access condition</param>
- /// <param name="options">blob request options</param>
- /// <param name="operationContext">An object that represents the context for the current operation.</param>
- public void SetBlobMetadata(ICloudBlob blob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
- {
- blob.SetMetadata(accessCondition, options, operationContext);
- }
- }
-}
View
63 WindowsAzurePowershell/src/ServiceManagement/Storage/Blob/ResourceModel/AzureStorageContainer.cs
@@ -1,63 +0,0 @@
-// ----------------------------------------------------------------------------------
-//
-// Copyright Microsoft Corporation
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// ----------------------------------------------------------------------------------
-
-namespace Microsoft.WindowsAzure.ServiceManagement.Storage.Blob.ResourceModel
-{
- using Microsoft.WindowsAzure.ServiceManagement.Storage.Common.ResourceModel;
- using Microsoft.WindowsAzure.Storage.Blob;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
-
- /// <summary>
- /// azure storage container
- /// </summary>
- public class AzureStorageContainer : AzureStorageBase
- {
- /// <summary>
- /// CloudBlobContainer object
- /// </summary>
- public CloudBlobContainer CloudBlobContainer { get; private set; }
-
- /// <summary>
- /// the permission of CloudBlobContainer
- /// </summary>
- public BlobContainerPermissions Permissions { get; private set; }
-
- /// <summary>
- /// the public accesss level of CloudBlobContainer
- /// </summary>
- public BlobContainerPublicAccessType PublicAccess { get; private set; }
-
- /// <summary>
- /// last modified of CloudBlobContainer
- /// </summary>
- public DateTimeOffset? LastModified { get; private set; }
-
- /// <summary>
- /// init azure storage container using CloudBlobContainer and BlobContainerPermissions
- /// </summary>
- /// <param name="container">CloudBlobContainer object</param>
- /// <param name="permissions">permissions of container</param>
- public AzureStorageContainer(CloudBlobContainer container, BlobContainerPermissions permissions)
- {
- CloudBlobContainer = container;
- Permissions = permissions;
- Name = container.Name;
- PublicAccess = permissions.PublicAccess;
- LastModified = container.Properties.LastModified;
- }
- }
-}
View
37 WindowsAzurePowershell/src/ServiceManagement/Storage/Common/ResourceModel/AzureStorageBase.cs
@@ -1,37 +0,0 @@
-// ----------------------------------------------------------------------------------
-//
-// Copyright Microsoft Corporation
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// ----------------------------------------------------------------------------------
-
-namespace Microsoft.WindowsAzure.ServiceManagement.Storage.Common.ResourceModel
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
-
- /// <summary>
- /// Base class for all azure storage object
- /// </summary>
- public class AzureStorageBase
- {
- /// <summary>
- /// Storage context
- /// </summary>
- public AzureStorageContext Context { get; set; }
-
- /// <summary>
- /// Azure storage object name
- /// </summary>
- public String Name { get; set; }
- }
-}
View
78 WindowsAzurePowershell/src/ServiceManagement/Storage/Common/ResourceModel/AzureStorageContext.cs
@@ -1,78 +0,0 @@
-// ----------------------------------------------------------------------------------
-//
-// Copyright Microsoft Corporation
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// ----------------------------------------------------------------------------------
-
-namespace Microsoft.WindowsAzure.ServiceManagement.Storage.Common.ResourceModel
-{
- using Microsoft.WindowsAzure.Storage;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
-
- /// <summary>
- /// Storage context
- /// </summary>
- public class AzureStorageContext
- {
- /// <summary>
- /// Storage account name used in this context
- /// </summary>
- public string StorageAccountName { get; private set; }
-
- /// <summary>
- /// Blob end point of the storage context
- /// </summary>
- public string BlobEndPoint { get; private set; }
-
- /// <summary>
- /// Table end point of the storage context
- /// </summary>
- public string TableEndPoint { get; private set; }
-
- /// <summary>
- /// Queue end point of the storage context
- /// </summary>
- public string QueueEndPoint { get; private set; }
-
- /// <summary>
- /// Self reference, it could enable New-AzureStorageContext can be used in pipeline
- /// </summary>
- public AzureStorageContext Context { get; private set; }
-
- /// <summary>
- /// Name place holder, and force pipeline to ignore this property
- /// </summary>
- public string Name { get; private set; }
-
- /// <summary>
- /// Storage account in context
- /// </summary>
- public CloudStorageAccount StorageAccount { get; private set; }
-
- /// <summary>
- /// Create a storage context usign cloud storage account
- /// </summary>
- /// <param name="account">cloud storage account</param>
- public AzureStorageContext(CloudStorageAccount account)
- {
- StorageAccount = account;
- BlobEndPoint = account.BlobEndpoint.ToString();
- TableEndPoint = account.TableEndpoint.ToString();
- QueueEndPoint = account.QueueEndpoint.ToString();
- StorageAccountName = account.Credentials.AccountName;
- Context = this;
- Name = String.Empty;
- }
- }
-}
View
59 WindowsAzurePowershell/src/ServiceManagement/Storage/Util/StorageExceptionUtil.cs
@@ -1,59 +0,0 @@
-// ----------------------------------------------------------------------------------
-//
-// Copyright Microsoft Corporation
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// ----------------------------------------------------------------------------------
-
-namespace Microsoft.WindowsAzure.ServiceManagement.Storage.Util
-{
- using Microsoft.WindowsAzure.Storage;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
-
- /// <summary>
- /// Storage exception utility
- /// </summary>
- public static class StorageExceptionUtil
- {
- /// <summary>
- /// Whether the storage exception is resource not found exception or not.
- /// </summary>
- /// <param name="e">StorageException from storage client</param>
- /// <returns>Whether the storageexception is caused by resource not found</returns>
- public static bool IsNotFoundException(this StorageException e)
- {
- return e.RequestInformation != null && e.RequestInformation.HttpStatusCode == 404;
- }
-
- /// <summary>
- /// Replace storage exception to expose more information in Message.
- /// </summary>
- /// <param name="e">StorageException from storage client</param>
- /// <returns>A new storage exception with detailed error message</returns>
- public static StorageException RepackStorageException(this StorageException e)
- {
- if (null != e.RequestInformation &&
- null != e.RequestInformation.HttpStatusMessage)
- {
- String msg = string.Format(
- "Error Message {0}. HTTP Status Code: {1} - HTTP Error Message: {2}",
- e.Message,
- e.RequestInformation.HttpStatusCode,
- e.RequestInformation.HttpStatusMessage);
- e = new StorageException(e.RequestInformation, msg, e);
- }
-
- return e;
- }
- }
-}
View
2  build.proj
@@ -232,7 +232,7 @@
Command="MSTest.exe /testcontainer:$(WebsitesTestDebug) /testsettings:$(TestSettings) /category:$(TestFilter) /resultsfile:$(TestOutputDirectory)\WebsitesDebug.trx"
ContinueOnError="false" />
<Exec
- Command="MSTest.exe /testcontainer:$(WebsitesTestDebug) /testsettings:$(TestSettings) /category:$(TestFilter) /resultsfile:$(TestOutputDirectory)\StorageDebug.trx"
+ Command="MSTest.exe /testcontainer:$(StorageTestDebug) /testsettings:$(TestSettings) /category:$(TestFilter) /resultsfile:$(TestOutputDirectory)\StorageDebug.trx"
ContinueOnError="false" />
</Target>
Please sign in to comment.
Something went wrong with that request. Please try again.