Skip to content

Vmss #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
Feb 23, 2016
Merged

Vmss #141

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
96b6c77
Add cmdlet to create Account SAS token.
EmmaZhu Oct 23, 2015
369ba96
Merge branch 'dev' of https://github.com/wastoresh/azure-powershell i…
EmmaZhu Nov 5, 2015
e886fab
Resolve a build issue.
EmmaZhu Nov 5, 2015
11a8813
Fix an issue of cannot indicate starttime and expirytime in New-Azure…
EmmaZhu Nov 6, 2015
2ee5fa5
Resolve a build issue.
EmmaZhu Nov 9, 2015
430d30a
Fix issue that doesn't throw out exceptions when the starting copying…
EmmaZhu Feb 2, 2016
7a2ccb0
Merge branch 'accountsas' of https://github.com/wastoresh/azure-power…
blueww Feb 3, 2016
909acb4
Bug fix: Make parameter mandatory
dihan0604 Feb 5, 2016
2b2f318
RDTask 5684669:[PSH] Support Protocal/IPAcl in Blob/File/Table/Queue SAS
blueww Feb 15, 2016
9ea5cb2
Merge branch 'dev' of https://github.com/wastoresh/azure-powershell i…
blueww Feb 16, 2016
34d24a4
Merge branch 'accountsas' of https://github.com/wastoresh/azure-power…
blueww Feb 16, 2016
8fbed7b
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
EmmaZhu Feb 16, 2016
1da2298
Merge branch 'dev' of https://github.com/wastoresh/azure-powershell i…
blueww Feb 16, 2016
0957564
RDTask 5684669:[PSH] Support Protocal/IPAcl in Blob/File/Table/Queue …
blueww Feb 17, 2016
83fce2c
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
blueww Feb 18, 2016
27056a5
Elastic Transactions GA
Feb 18, 2016
ba626a2
fix a indentation from code review
blueww Feb 19, 2016
8e5494d
Update CONTRIBUTING.md
vors Feb 20, 2016
feaf59b
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
dihan0604 Feb 22, 2016
95eef6b
Fixing profile tests in ASM.
Feb 22, 2016
e4a3b55
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
blueww Feb 22, 2016
4ee7514
RDBug 5795841:[PSH] Failed to upload zero size of file to Azure File:…
blueww Feb 22, 2016
32debb4
Fixed XmlProfileSerializer bug related to ProfileData namespace chang…
Feb 22, 2016
40edb36
Fixed Resource solution complain for BCL and ServiceManagement refere…
Feb 22, 2016
c91c91a
fixed Commands.Profile.Test.csproj reference to ServiceManagement.
Feb 22, 2016
a512681
Update CONTRIBUTING.md
vors Feb 22, 2016
51da91d
enable ER test
dihan0604 Feb 23, 2016
83f197f
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
blueww Feb 23, 2016
9045a4c
Fixed CanClearStorageAccountForSMProfile test
Feb 23, 2016
33e913c
Merge pull request #1831 from torsteng/patch-2
Feb 23, 2016
bfeebb8
Change the PR as comments from Hovsep
blueww Feb 23, 2016
45538f2
Merge pull request #1838 from vors/patch-1
Feb 23, 2016
f088168
Merge pull request #1828 from wastoresh/dev
Feb 23, 2016
c06cd8f
Merge pull request #1841 from hovsepm/dev
Feb 23, 2016
c2b149e
Merge pull request #1844 from dihan0604/dev
Feb 23, 2016
83b4174
Merge pull request #423 from Azure/dev
huangpf Feb 23, 2016
2127c3e
Combine PowerOff & Deallocate
huangpf Feb 23, 2016
21664b5
Merge branch 'vmss' of https://github.com/huangpf/azure-powershell in…
huangpf Feb 23, 2016
2a33557
Remove PowerOff Cmdlets
huangpf Feb 23, 2016
877ad63
Merge pull request #424 from Azure/dev
huangpf Feb 23, 2016
3feedd6
Merge pull request #425 from huangpf/dev
huangpf Feb 23, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Contribute Code or Provide Feedback

If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](http://windowsazure.github.com/guidelines.html).
If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](http://azure.github.io/guidelines/).

If you encounter any bugs with Microsoft Azure PowerShell please file an issue in the [Issues](https://github.com/Azure/azure-powershell/issues) section of the project.
10 changes: 10 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
* Set-AzureLogicAppAccessKey
* Set-AzureLogicApp
* Stop-AzureLogicAppRun
* Azure Storage
* Added cmdlet to generate SAS token against storage account
- New-AzureStorageAccountSASToken
* Added IPAddressOrRange/Protocol support in cmdlets to generate SAS token against blob, container, file, share, table, queue
- New-AzureStorageBlobSASToken
- New-AzureStorageContainerSASToken
- New-AzureStorageFileSASToken
- New-AzureStorageShareSASToken
- New-AzureStorageQueueSASToken
- New-AzureStorageTableSASToken

## 2016.02.04 version 1.2.1
* Fix installer issue - remove PSGallery modules on install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AssemblyName>Commands.Common.Authentication</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<TargetFrameworkProfile />
<RestorePackages>true</RestorePackages>
<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
<NuGetPackageImportStamp>06e19c11</NuGetPackageImportStamp>
Expand Down Expand Up @@ -51,7 +51,8 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Hyak.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Hyak.Common.1.0.3\lib\net45\Hyak.Common.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Hyak.Common.1.0.3\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -178,5 +179,4 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ public bool Deserialize(string contents, AzureSMProfile profile)
DeserializeErrors = new List<string>();

DataContractSerializer serializer = new DataContractSerializer(typeof(ProfileData));

// For backward compatibility since namespace of ProfileData has been changed
// we need to replace previous namespace with the current one
if (!string.IsNullOrWhiteSpace(contents))
{
contents = contents.Replace(
"http://schemas.datacontract.org/2004/07/Microsoft.Azure.Common.Authentication",
"http://schemas.datacontract.org/2004/07/Microsoft.Azure.Commands.Common.Authentication");
}

using (MemoryStream s = new MemoryStream(Encoding.UTF8.GetBytes(contents ?? "")))
{
data = (ProfileData)serializer.ReadObject(s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,16 @@ public Task<string> StartCopyAsync(CloudBlob blob, Uri source, AccessCondition s
throw new NotImplementedException();
}

/// <summary>
/// Get the SAS token for an account.
/// </summary>
/// <param name="sharedAccessAccountPolicy">Shared access policy to generate the SAS token.</param>
/// <returns>Account SAS token.</returns>
public string GetStorageAccountSASToken(SharedAccessAccountPolicy sharedAccessAccountPolicy)
{
throw new NotImplementedException();
}

/// <summary>
/// The storage context
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet
using Microsoft.WindowsAzure.Commands.Storage.Common;
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage;

[Cmdlet(VerbsCommon.New, StorageNouns.BlobSas, DefaultParameterSetName = BlobNamePipelineParmeterSetWithPermission), OutputType(typeof(String))]
public class NewAzureStorageBlobSasTokenCommand : StorageCloudBlobCmdletBase
Expand Down Expand Up @@ -80,6 +81,12 @@ public string Policy
ParameterSetName = BlobPipelineParameterSetWithPermision)]
public string Permission { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Protocol can be used in the request with this SAS token.")]
public SharedAccessProtocol Protocol { get; set; }

[Parameter(Mandatory = false, HelpMessage = "IP, or IP range ACL (access control list) that the request would be accepted from by Azure Storage.")]
public string IPAddressOrRange { get; set; }

[Parameter(HelpMessage = "Start Time")]
public DateTime? StartTime { get; set; }

Expand Down Expand Up @@ -133,7 +140,7 @@ public override void ExecuteCmdlet()
SharedAccessBlobPolicy accessPolicy = new SharedAccessBlobPolicy();
bool shouldSetExpiryTime = SasTokenHelper.ValidateContainerAccessPolicy(Channel, blob.Container.Name, accessPolicy, accessPolicyIdentifier);
SetupAccessPolicy(accessPolicy, shouldSetExpiryTime);
string sasToken = GetBlobSharedAccessSignature(blob, accessPolicy, accessPolicyIdentifier);
string sasToken = GetBlobSharedAccessSignature(blob, accessPolicy, accessPolicyIdentifier, Protocol, Util.SetupIPAddressOrRangeForSAS(IPAddressOrRange));

if (FullUri)
{
Expand All @@ -154,10 +161,10 @@ public override void ExecuteCmdlet()
/// <param name="accessPolicy">SharedAccessBlobPolicy object</param>
/// <param name="policyIdentifier">The existing policy identifier.</param>
/// <returns></returns>
private string GetBlobSharedAccessSignature(CloudBlob blob, SharedAccessBlobPolicy accessPolicy, string policyIdentifier)
private string GetBlobSharedAccessSignature(CloudBlob blob, SharedAccessBlobPolicy accessPolicy, string policyIdentifier, SharedAccessProtocol protocol, IPAddressOrRange iPAddressOrRange)
{
CloudBlobContainer container = blob.Container;
return blob.GetSharedAccessSignature(accessPolicy, policyIdentifier);
return blob.GetSharedAccessSignature(accessPolicy, null, policyIdentifier, protocol, iPAddressOrRange);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet
using Microsoft.WindowsAzure.Commands.Storage.Common;
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage;

[Cmdlet(VerbsCommon.New, StorageNouns.ContainerSas), OutputType(typeof(String))]
public class NewAzureStorageContainerSasTokenCommand : StorageCloudBlobCmdletBase
Expand Down Expand Up @@ -51,9 +52,15 @@ public string Policy
private string accessPolicyIdentifier;

[Parameter(HelpMessage = "Permissions for a container. Permissions can be any not-empty subset of \"rwdl\".",
ParameterSetName = SasPermissionParameterSet)]
ParameterSetName = SasPermissionParameterSet)]
public string Permission { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Protocol can be used in the request with this SAS token.")]
public SharedAccessProtocol Protocol { get; set; }

[Parameter(Mandatory = false, HelpMessage = "IP, or IP range ACL (access control list) that the request would be accepted from by Azure Storage.")]
public string IPAddressOrRange { get; set; }

[Parameter(HelpMessage = "Start Time")]
public DateTime? StartTime { get; set; }

Expand Down Expand Up @@ -98,7 +105,7 @@ public override void ExecuteCmdlet()
SharedAccessBlobPolicy accessPolicy = new SharedAccessBlobPolicy();
bool shouldSetExpiryTime = SasTokenHelper.ValidateContainerAccessPolicy(Channel, container.Name, accessPolicy, accessPolicyIdentifier);
SetupAccessPolicy(accessPolicy, shouldSetExpiryTime);
string sasToken = container.GetSharedAccessSignature(accessPolicy, accessPolicyIdentifier);
string sasToken = container.GetSharedAccessSignature(accessPolicy, accessPolicyIdentifier, Protocol, Util.SetupIPAddressOrRangeForSAS(IPAddressOrRange));

if (FullUri)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ private async Task StartCopyFromBlob(long taskId, IStorageBlobManagement destCha
// Opened workitem 1487579 to track this.
throw new InvalidOperationException(Resources.DestinationBlobTypeNotMatch);
}
else
{
throw;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
<Compile Include="Common\BlobToFileSystemNameResolver.cs" />
<Compile Include="Blob\Cmdlet\StartAzureStorageBlobCopy.cs" />
<Compile Include="Blob\Cmdlet\StopAzureStorageBlobCopy.cs" />
<Compile Include="Common\Cmdlet\NewAzureStorageAccountSasToken.cs" />
<Compile Include="Common\Cmdlet\SetAzureStorageCORSRule.cs" />
<Compile Include="Common\Cmdlet\GetAzureStorageCORSRule.cs" />
<Compile Include="Common\Cmdlet\GetAzureStorageServiceLogging.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// ----------------------------------------------------------------------------------
//
// 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.Commands.Storage.Common.Cmdlet
{
using System;
using System.Management.Automation;
using System.Security.Permissions;
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
using Microsoft.WindowsAzure.Storage;

[Cmdlet(VerbsCommon.New, StorageNouns.AccountSas), OutputType(typeof(String))]
public class NewAzureStorageAccountSasTokenCommand : StorageCloudBlobCmdletBase
{
[Parameter(Mandatory = true, HelpMessage = "Service type that this SAS token applies to.")]
public SharedAccessAccountServices Service { get; set; }

[Parameter(Mandatory = true, HelpMessage = "Resource type that this SAS token applies to.")]
public SharedAccessAccountResourceTypes ResourceType { get; set; }

[Parameter(Mandatory = true, HelpMessage = "Permissions.")]
public string Permission { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Protocol can be used in the request with this SAS token.")]
public SharedAccessProtocol Protocol { get; set; }

[Parameter(Mandatory = false, HelpMessage = "IP, or IP range ACL (access control list) that the request would be accepted from by Azure Storage.")]
public string IPAddressOrRange { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Start Time")]
public DateTime? StartTime { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Expiry Time")]
public DateTime? ExpiryTime { get; set; }

// Overwrite the useless parameter
public override int? ServerTimeoutPerRequest { get; set; }
public override int? ClientTimeoutPerRequest { get; set; }
public override int? ConcurrentTaskCount { get; set; }

/// <summary>
/// Initializes a new instance of the NewAzureStorageAccountSasTokenCommand class.
/// </summary>
public NewAzureStorageAccountSasTokenCommand()
: this(null)
{
}

/// <summary>
/// Initializes a new instance of the NewAzureStorageAccountSasTokenCommand class.
/// </summary>
/// <param name="channel">IStorageBlobManagement channel</param>
public NewAzureStorageAccountSasTokenCommand(IStorageBlobManagement channel)
{
Channel = channel;
EnableMultiThread = false;
}

/// <summary>
/// Execute command
/// </summary>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void ExecuteCmdlet()
{
var sharedAccessPolicy = new SharedAccessAccountPolicy()
{
Permissions = SetupAccessPolicyPermission(this.Permission),
Services = Service,
ResourceTypes = ResourceType,
Protocols = Protocol,
IPAddressOrRange = Util.SetupIPAddressOrRangeForSAS(this.IPAddressOrRange)
};

DateTimeOffset? accessStartTime;
DateTimeOffset? accessEndTime;
SasTokenHelper.SetupAccessPolicyLifeTime(StartTime, ExpiryTime,
out accessStartTime, out accessEndTime, true);
sharedAccessPolicy.SharedAccessStartTime = accessStartTime;
sharedAccessPolicy.SharedAccessExpiryTime = accessEndTime;

this.WriteObject(Channel.GetStorageAccountSASToken(sharedAccessPolicy));
}

/// <summary>
/// Set up access policy permission
/// </summary>
/// <param name="policy">SharedAccessBlobPolicy object</param>
/// <param name="permission">Permisson</param>
internal SharedAccessAccountPermissions SetupAccessPolicyPermission(string permission)
{
if (string.IsNullOrEmpty(permission)) return SharedAccessAccountPermissions.None;

SharedAccessAccountPermissions accountPermission = SharedAccessAccountPermissions.None;
permission = permission.ToLower();
foreach (char op in permission)
{
switch (op)
{
case StorageNouns.Permission.Read:
case StorageNouns.Permission.Query:
accountPermission |= SharedAccessAccountPermissions.Read;
break;
case StorageNouns.Permission.Process:
accountPermission |= SharedAccessAccountPermissions.ProcessMessages;
break;
case StorageNouns.Permission.Write:
accountPermission |= SharedAccessAccountPermissions.Write;
break;
case StorageNouns.Permission.Add:
accountPermission |= SharedAccessAccountPermissions.Add;
break;
case StorageNouns.Permission.Create:
accountPermission |= SharedAccessAccountPermissions.Create;
break;
case StorageNouns.Permission.Update:
accountPermission |= SharedAccessAccountPermissions.Update;
break;
case StorageNouns.Permission.Delete:
accountPermission |= SharedAccessAccountPermissions.Delete;
break;
case StorageNouns.Permission.List:
accountPermission |= SharedAccessAccountPermissions.List;
break;
default:
throw new ArgumentException(string.Format(Resources.InvalidAccessPermission, op));
}
}

return accountPermission;
}
}
}
10 changes: 10 additions & 0 deletions src/Common/Storage/Commands.Storage/Common/StorageNouns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public static class StorageNouns
/// </summary>
public const string StorageCORSRule = "AzureStorageCORSRule";

/// <summary>
/// Azure storage account sas
/// </summary>
public const string AccountSas = "AzureStorageAccountSASToken";

/// <summary>
/// Azure storage container sas
/// </summary>
Expand Down Expand Up @@ -214,6 +219,11 @@ public static class Permission
/// Query permission
/// </summary>
public const char Query = 'q';

/// <summary>
/// Create permission.
/// </summary>
public const char Create = 'c';
}
}
}
16 changes: 16 additions & 0 deletions src/Common/Storage/Commands.Storage/Common/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,21 @@ public static CloudBlob GetBlobReference(Uri blobUri, StorageCredentials storage
blobUri));
}
}

public static IPAddressOrRange SetupIPAddressOrRangeForSAS(string inputIPACL)
{
if (string.IsNullOrEmpty(inputIPACL)) return null;

int separator = inputIPACL.IndexOf('-');

if (-1 == separator)
{
return new IPAddressOrRange(inputIPACL);
}
else
{
return new IPAddressOrRange(inputIPACL.Substring(0, separator), inputIPACL.Substring(separator + 1));
}
}
}
}
Loading