Skip to content
Merged

. #44

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0a53a49
Add back removed resourcemanager startups cript
markcowl Oct 7, 2015
313c26e
Updating scripts for new module split
markcowl Oct 7, 2015
7fb3abc
Merge branch 'release-1.0.0-preview' of github.com:Azure/azure-powers…
markcowl Oct 7, 2015
7b53ee3
Fix badly named cmdlets in Profile and Keyvault
jianghaolu Oct 8, 2015
2cc2548
Merge branch 'release-1.0.0-preview' of github.com:Azure/azure-powers…
jianghaolu Oct 8, 2015
d7ae6f3
Fix remaining issues with storage account and DSC/IAAS extensions
markcowl Oct 8, 2015
0ce925d
Additional usages of raw subscription
markcowl Oct 8, 2015
d1f225b
Merge pull request #1082 from markcowl/resourcescript
markcowl Oct 8, 2015
fc33f7f
Merge pull request #1084 from jianghaolu/rename
devigned Oct 8, 2015
836da7b
Merge pull request #1086 from markcowl/storagedsc
markcowl Oct 8, 2015
834fec3
Increased minor version of all packages to 0.10.0
stankovski Oct 8, 2015
7172ad5
Support SM/RM cmdlets execution with RP registration
Oct 8, 2015
eb56c84
Merge pull request #1088 from stankovski/release-1.0.0-preview
stankovski Oct 8, 2015
d4b8469
Bumped up MSI and AzureRM version to 1.0
stankovski Oct 8, 2015
938d572
Removed verbose setting
stankovski Oct 8, 2015
93b9c68
Merge pull request #1089 from ogail/release-1.0.0-preview
Oct 8, 2015
7c456c5
Merge pull request #1090 from stankovski/release-1.0.0-preview
stankovski Oct 8, 2015
9c346a6
Update Stream Analytics PowerShell
atpham256 Oct 8, 2015
3cd6723
Added tag "Azure" to packages
stankovski Oct 8, 2015
2c6b2be
Merge pull request #1092 from stankovski/release-1.0.0-preview
stankovski Oct 8, 2015
11c2382
Merge pull request #1091 from atpham256/dev
ogail Oct 8, 2015
c9b0b24
Add incompatible version check [Fixes #105258902]
markcowl Oct 9, 2015
115ae88
Fix indentation in new script function
markcowl Oct 9, 2015
0e27fbd
Merge pull request #1093 from markcowl/installerupdate
Oct 9, 2015
a661f2b
fixing the script for32-bit machines
markcowl Oct 9, 2015
59f1a01
Fix issue with context changes not copying the token cache
markcowl Oct 9, 2015
b3c26e5
Ensure that TokenCache is transmitted to context when context is set
markcowl Oct 9, 2015
671fcef
Merge pull request #1094 from markcowl/installerupdate
markcowl Oct 9, 2015
c72da97
Update package metadata, license uri, and signing
markcowl Oct 9, 2015
1bd4cbf
Added changes to ARM management cmdlets
ravbhatnagar Oct 9, 2015
1d44122
Merge pull request #1098 from ravbhatnagar/release-1.0.0-preview
Oct 9, 2015
a3e8da7
Merge pull request #1097 from markcowl/signscript
markcowl Oct 9, 2015
09c3909
Merge pull request #1099 from Azure/release-1.0.0-preview
markcowl Oct 10, 2015
38f0e66
Merge pull request #1100 from Azure/master
markcowl Oct 10, 2015
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
Prev Previous commit
Next Next commit
Fix remaining issues with storage account and DSC/IAAS extensions
  • Loading branch information
markcowl committed Oct 8, 2015
commit d7ae6f31140cfcba9699cb63ba6c86cc4fb6ab4b
60 changes: 60 additions & 0 deletions src/Common/Commands.Common/AzureSubscriptionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.Common.Authentication.Models;

namespace Microsoft.WindowsAzure.Commands.Common
{
public static class AzureSubscriptionExtensions
{

public static string GetStorageAccountName(this AzureSubscription subscription)
{
if (subscription == null || !subscription.IsPropertySet(AzureSubscription.Property.StorageAccount))
{
return null;
}

var result = subscription.GetProperty(AzureSubscription.Property.StorageAccount);
if (!string.IsNullOrWhiteSpace(result))
{
try
{
var pairs = result.Split(new char[]{';'}, StringSplitOptions.RemoveEmptyEntries);
foreach (var pair in pairs)
{
var sides = pair.Split(new char[] {'='}, 2, StringSplitOptions.RemoveEmptyEntries);
if (string.Equals("AccountName", sides[0].Trim(), StringComparison.OrdinalIgnoreCase))
{
result = sides[1].Trim();
break;
}
}
}
catch
{
// if there are any errors, return the unchanged account name
}
}

return result;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,10 @@ internal static StorageCredentials GetStorageCredentials(this AzureSMCmdlet cmdl
}
else
{
var storageAccountName = cmdlet.Profile.Context.Subscription.GetProperty(AzureSubscription.Property.StorageAccount);

var storageClient = AzureSession.ClientFactory.CreateClient<StorageManagementClient>(
cmdlet.Profile, cmdlet.Profile.Context.Subscription, AzureEnvironment.Endpoint.ServiceManagement);

if (!string.IsNullOrEmpty(storageAccountName) && storageClient != null)
var storageAccount = cmdlet.Profile.Context.GetCurrentStorageAccount();
if (storageAccount != null)
{
var keys = storageClient.StorageAccounts.GetKeys(storageAccountName);

if (keys != null)
{
var storageAccountKey = string.IsNullOrEmpty(keys.PrimaryKey) ? keys.SecondaryKey : keys.PrimaryKey;

credentials = new StorageCredentials(storageAccountName, storageAccountKey);
}
credentials = storageAccount.Credentials;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,5 @@ public PSAzureSubscription(AzureSubscription subscription, AzureSMProfile profil
public string CurrentStorageAccountName { get; set; }

public string TenantId { get; set; }

public string GetAccountName()
{
var result = CurrentStorageAccountName;
if (!string.IsNullOrWhiteSpace(result))
{
try
{
var pairs = result.Split(new char[]{';'}, StringSplitOptions.RemoveEmptyEntries);
foreach (var pair in pairs)
{
var sides = pair.Split(new char[] {'='}, 2, StringSplitOptions.RemoveEmptyEntries);
if (string.Equals("AccountName", sides[0].Trim(), StringComparison.OrdinalIgnoreCase))
{
result = sides[1].Trim();
break;
}
}
}
catch
{
// if there are any errors, return the unchanged account name
}
}

return result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ private PublishContext CreatePublishContext(
// If there's no storage service provided, try using the default one
if (string.IsNullOrEmpty(storageServiceName))
{
storageServiceName = Subscription.GetProperty(AzureSubscription.Property.StorageAccount);
storageServiceName = Subscription.GetStorageAccountName();
}

ServiceSettings serviceSettings = ServiceSettings.LoadDefault(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Collections.Generic;
using System.Management.Automation;
using Microsoft.Azure.Common.Authentication.Models;
using Microsoft.WindowsAzure.Commands.Common;
using Microsoft.WindowsAzure.Commands.Utilities.Websites;
using Microsoft.WindowsAzure.Commands.Utilities.Websites.Common;
using Microsoft.WindowsAzure.Commands.Utilities.Websites.Services.DeploymentEntities;
Expand Down Expand Up @@ -68,8 +69,14 @@ public override void ExecuteCmdlet()
}
else if (TableStorage.IsPresent || BlobStorage.IsPresent)
{
properties[DiagnosticProperties.StorageAccountName] = string.IsNullOrEmpty(StorageAccountName) ?
Profile.Context.Subscription.GetProperty(AzureSubscription.Property.StorageAccount) : StorageAccountName;
if (string.IsNullOrWhiteSpace(StorageAccountName))
{
properties[DiagnosticProperties.StorageAccountName] = Profile.Context.Subscription.GetStorageAccountName();
}
else
{
properties[DiagnosticProperties.StorageAccountName] = StorageAccountName;
}

if (TableStorage.IsPresent)
{
Expand Down