-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1100 from Azure/master
Merge master -> dev
- Loading branch information
Showing
70 changed files
with
434 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -442,6 +442,5 @@ public static void ClearCurrentStorageAccount(bool clearSMContext = false) | |
} | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 15 additions & 1 deletion
16
src/ResourceManager/Common/Commands.ResourceManager.Common/AccessTokenExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMProfileExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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.Commands.ResourceManager.Common.Properties; | ||
using Microsoft.Azure.Common.Authentication.Models; | ||
using Microsoft.IdentityModel.Clients.ActiveDirectory; | ||
|
||
namespace Microsoft.Azure.Commands.ResourceManager.Common | ||
{ | ||
public static class AzureRMProfileExtensions | ||
{ | ||
/// <summary> | ||
/// Set the context for the current profile, preserving token cache information | ||
/// </summary> | ||
/// <param name="profile">The profile to change the context for</param> | ||
/// <param name="newContext">The new context, with no token cache information.</param> | ||
public static void SetContextWithCache(this AzureRMProfile profile, AzureContext newContext) | ||
{ | ||
if (profile == null) | ||
{ | ||
throw new ArgumentNullException("profile", Resources.ProfileCannotBeNull); | ||
} | ||
|
||
if (newContext == null) | ||
{ | ||
throw new ArgumentNullException("newContext", Resources.ContextCannotBeNull); | ||
} | ||
|
||
newContext.TokenCache = TokenCache.DefaultShared.Serialize(); | ||
profile.Context = newContext; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.