Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
dcaac6a
initial commit
Nov 17, 2014
dc4658d
Merge branch 'master' of github.com:ogail/azure-powershell-pr into dev
ogail Nov 18, 2014
b00fe53
fix whitespace bugs for hub and pipeline as well as add some negative…
jackmagic313 Nov 18, 2014
1f40993
Bug1730534 [PowerShell for XSMB] enable accepting objects from pipeli…
zhenyud Nov 11, 2014
4606dea
delete corrupted tokencache
yugangw-msft Nov 20, 2014
1e53a65
avoid test flakeness caused by static field
yugangw-msft Nov 20, 2014
38b5c11
for ADF stub cmdlet
jackmagic313 Nov 20, 2014
f2856a6
Test update: download all vhds and package files from blob storage.
Nov 20, 2014
b1ff8c0
small fix for get-help
jackmagic313 Nov 20, 2014
37c423f
Provide warning if specifying more than one job output type
travismc1 Nov 21, 2014
25585aa
changed warning message
jackmagic313 Nov 21, 2014
1ff444e
[PowerShell] 3 P1 bug fix
zhenyud Nov 21, 2014
5fb8767
Merge pull request #4 from yugangw-msft/tokencache
amarzavery Nov 21, 2014
768da38
Add support to get jobs with AADOAuth and Basic auth.
vivsriaus Nov 21, 2014
ce00ba9
Merge pull request #1 from ogail/dev
ogail Nov 21, 2014
db292ec
Merge pull request #5 from travismc1/WarningForJobOutputType
ogail Nov 21, 2014
250c147
Addressed feedback
vivsriaus Nov 21, 2014
5e44daa
temporarily removed E2E tests
jackmagic313 Nov 21, 2014
fd2ce9a
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
huangpf Nov 22, 2014
274e42d
Merge pull request #7 from vivsriaus/dev
ogail Nov 22, 2014
c1f8abd
Fixing build warnings: Episode 1 Attempt 1
Nov 22, 2014
dea4013
Fix using in memory subscription with provider registration
amarzavery Nov 22, 2014
342136e
added test to installationtests
amarzavery Nov 22, 2014
dec32f0
minor help content fix
zhenyud Nov 24, 2014
10833de
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
huangpf Nov 24, 2014
2ff9ce1
add online links for some Cmdlets
zhenyud Nov 24, 2014
d0f2632
Retain auth info (AADOAuth and Basic) when getting/updating jobs
vivsriaus Nov 24, 2014
177e1c9
Merge pull request #8 from amarzavery/rp
amarzavery Nov 25, 2014
ef3d20b
Merge pull request #11 from vivsriaus/dev
ogail Nov 25, 2014
f01ca1b
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
jackmagic313 Nov 25, 2014
8ed741e
minor fix for uppercase to lowercase
zhenyud Nov 26, 2014
2143e5e
Calculating the connection strings in the client
yoavrubin Nov 26, 2014
1048b8c
Fixing Resize Gateway cmdlet and adding SetIPsecParameters and GetIPs…
Nov 26, 2014
3685970
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
Nov 26, 2014
df0d205
Merge pull request #2 from jackmagic313/dev
ogail Nov 26, 2014
3f466e8
reverting changes of the non-auditing libraries
yoavrubin Nov 27, 2014
d990469
reverting change in the tests project
yoavrubin Nov 27, 2014
c20d25c
Merge branch 'dev' of github.com:Azure/azure-powershell into NoWarning
Nov 28, 2014
95d922d
Merge pull request #14 from yoavrubin/master
Nov 28, 2014
ae2c050
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
huangpf Nov 29, 2014
da403df
fix test
huangpf Nov 29, 2014
5f1eee7
Episode 1 Attempt 2
Nov 29, 2014
2c80364
Merge branch 'dev' of github.com:Azure/azure-powershell into NoWarning
Nov 29, 2014
916b62c
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
Dec 1, 2014
1454931
Updating all of the projects to have the latest Microsoft.WindowsAzur…
Dec 1, 2014
8d8373c
Moving "using" statements outside of the namespace.
Dec 1, 2014
88ccfd7
Attempting to fix the build errors I'm getting in my pull request, bu…
Dec 1, 2014
860fa8e
Trying to fix the pull request build errors again (adding PublicKeyTo…
Dec 1, 2014
334b96a
Remove non-existing New-AzureVMSqlServerExtension
ogail Dec 1, 2014
1f53212
fix role configuration deserialization
huangpf Dec 1, 2014
9080531
Merge pull request #20 from Azure/master
ogail Dec 1, 2014
60b964d
Merge pull request #12 from wastoresh/dev
ogail Dec 1, 2014
f1adcf5
Trying again to fix the pull request build.
Dec 1, 2014
6f6347e
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
Dec 1, 2014
92a0732
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
huangpf Dec 1, 2014
5d70a71
Missed a couple more.
Dec 1, 2014
85db4ba
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
huangpf Dec 1, 2014
451839b
Merge branch 'dev' of https://github.com/AzureRT/azure-powershell int…
huangpf Dec 1, 2014
a921c0f
Missed a typo.
Dec 1, 2014
a277131
Merge pull request #1 from huangpf/dev
AzureRT Dec 1, 2014
5cc4704
Changing csproj files back to what they were before I started, except…
Dec 1, 2014
a5b1c1f
Updating the reference to the common libraries to be 1.4.1
Dec 2, 2014
d43f7d4
Adding documentation for the Network module.
Dec 2, 2014
8379ab4
Merge branch 'dev' of github.com:Azure/azure-powershell into NoWarning
Dec 3, 2014
dbaa515
Merge pull request #22 from AzureRT/dev
Dec 3, 2014
fc5543e
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
Dec 3, 2014
797d018
Putting get and set on the same line.
Dec 3, 2014
42807ee
Merge pull request #17 from hovsepm/NoWarning
Dec 3, 2014
52721ea
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
Dec 3, 2014
9af8c44
Fixing select-Azuresubscription bug (3134567)
Dec 3, 2014
5d875f2
Fixing failing tests
Dec 3, 2014
2aaab88
Merge pull request #23 from hovsepm/subscription
ogail Dec 3, 2014
ebdf0ea
Removing the network help psd1 file
Dec 3, 2014
18dd916
Merge pull request #15 from daschult/dev
ogail Dec 3, 2014
a4afff5
Update Batch cmdlets to Batch MAML 1.1.6-preview
cwickham3 Dec 3, 2014
bcb9132
Remove app.config from project file
cwickham3 Dec 4, 2014
04137b7
Merge pull request #24 from cwickham3/dev
stankovski Dec 4, 2014
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
1 change: 0 additions & 1 deletion ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Select-AzureSubscription: fixed output types in default and PassThru mode
* Compute
* Get-AzureVMSqlServerExtension
* New-AzureVMSqlServerExtension
* Set-AzureVMSqlServerExtension
* Remove-AzureVMSqlServerExtension
* HDInsight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
</Reference>
<Reference Include="Microsoft.WindowsAzure.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Common.1.4.0\lib\net45\Microsoft.WindowsAzure.Common.dll</HintPath>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Common.1.4.1\lib\net45\Microsoft.WindowsAzure.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Common.NetFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Common.1.4.0\lib\net45\Microsoft.WindowsAzure.Common.NetFramework.dll</HintPath>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Common.1.4.1\lib\net45\Microsoft.WindowsAzure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.2.0.3\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Commands.Common.Storage/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<package id="Microsoft.Data.OData" version="5.6.0" targetFramework="net45" />
<package id="Microsoft.Data.Services.Client" version="5.6.0" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Common" version="1.4.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Common.Dependencies" version="1.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Common" version="1.4.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Common.Dependencies" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="3.1.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Commands.Common.Test/Commands.Common.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.WindowsAzure.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Common.1.4.0\lib\net45\Microsoft.WindowsAzure.Common.dll</HintPath>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Common.1.4.1\lib\net45\Microsoft.WindowsAzure.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Common.NetFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Common.1.4.0\lib\net45\Microsoft.WindowsAzure.Common.NetFramework.dll</HintPath>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Common.1.4.1\lib\net45\Microsoft.WindowsAzure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.2.0.3\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
Expand Down
89 changes: 78 additions & 11 deletions src/Common/Commands.Common.Test/Common/ProfileClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void ProfileMigratesAccountsAndDefaultSubscriptions()
Assert.Equal("https://api-dogfood.resources.windows-int.net", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.ResourceManager]);
Assert.Equal("https://management-preview.core.windows-int.net/", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.ServiceManagement]);
Assert.Equal(".database.windows.net", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix]);

// Verify subscriptions
Assert.Equal(3, client.Profile.Subscriptions.Count);
Assert.False(client.Profile.Subscriptions.ContainsKey(new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E")));
Expand Down Expand Up @@ -157,7 +157,7 @@ public void ProfileMigratesAccountsSkipsBadOnesAndBacksUpFile()

// Verify Environment migration
Assert.Equal(2, client.Profile.Environments.Count);

// Verify subscriptions
Assert.Equal(3, client.Profile.Subscriptions.Count);
Assert.True(client.Profile.Subscriptions.ContainsKey(new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")));
Expand All @@ -168,7 +168,7 @@ public void ProfileMigratesAccountsSkipsBadOnesAndBacksUpFile()

Assert.True(client.Profile.Subscriptions.ContainsKey(new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")));
Assert.Equal("Test Bad Cert", client.Profile.Subscriptions[new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")].Name);

// Verify accounts
Assert.Equal(2, client.Profile.Accounts.Count);
Assert.Equal("test@mail.com", client.Profile.Accounts["test@mail.com"].Id);
Expand Down Expand Up @@ -204,10 +204,10 @@ public void ProfileMigratesCorruptedFileAndCreatedBackup()

// Verify Environment migration
Assert.Equal(2, client.Profile.Environments.Count);

// Verify subscriptions
Assert.Equal(0, client.Profile.Subscriptions.Count);

// Verify accounts
Assert.Equal(0, client.Profile.Accounts.Count);

Expand Down Expand Up @@ -258,7 +258,7 @@ public void AddAzureAccountReturnsAccountWithAllSubscriptionsInRdfeMode()
ProfileClient.DataStore = dataStore;
ProfileClient client = new ProfileClient();

var account = client.AddAccountAndLoadSubscriptions(new AzureAccount { Id = "test", Type = AzureAccount.AccountType.User }, AzureEnvironment.PublicEnvironments[ EnvironmentName.AzureCloud], null);
var account = client.AddAccountAndLoadSubscriptions(new AzureAccount { Id = "test", Type = AzureAccount.AccountType.User }, AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], null);

Assert.Equal("test", account.Id);
Assert.Equal(3, account.GetSubscriptions(client.Profile).Count);
Expand Down Expand Up @@ -603,7 +603,7 @@ public void SetAzureEnvironmentUpdatesEnvironment()
Assert.Equal(2, client.Profile.Environments.Count);

Assert.Throws<ArgumentNullException>(() => client.AddOrSetEnvironment(null));

var env2 = client.AddOrSetEnvironment(azureEnvironment);
Assert.Equal(env2.Name, azureEnvironment.Name);
Assert.NotNull(env2.Endpoints[AzureEnvironment.Endpoint.ServiceManagement]);
Expand Down Expand Up @@ -672,7 +672,7 @@ public void AddOrSetAzureSubscriptionChecksAndUpdates()
Assert.Equal(subscription, azureSubscription1);
Assert.Throws<ArgumentNullException>(() => client.AddOrSetSubscription(null));
Assert.Throws<ArgumentNullException>(() => client.AddOrSetSubscription(
new AzureSubscription { Id = new Guid(), Environment = null, Name = "foo"}));
new AzureSubscription { Id = new Guid(), Environment = null, Name = "foo" }));
}

[Fact]
Expand Down Expand Up @@ -792,7 +792,7 @@ public void RefreshSubscriptionsWorksWithMooncake()
MockDataStore dataStore = new MockDataStore();
ProfileClient.DataStore = dataStore;
ProfileClient client = new ProfileClient();

client.Profile.Accounts[azureAccount.Id] = azureAccount;

var subscriptions = client.RefreshSubscriptions(client.Profile.Environments[EnvironmentName.AzureChinaCloud]);
Expand Down Expand Up @@ -878,7 +878,7 @@ public void SetAzureSubscriptionAsDefaultSetsDefaultAndCurrent()
Assert.Equal(azureSubscription2.Id, client.Profile.DefaultSubscription.Id);
Assert.Equal(azureSubscription2.Id, AzureSession.CurrentContext.Subscription.Id);
Assert.Throws<ArgumentException>(() => client.SetSubscriptionAsDefault("bad", null));
Assert.Throws<ArgumentNullException>(() => client.SetSubscriptionAsDefault(null, null));
Assert.Throws<ArgumentException>(() => client.SetSubscriptionAsDefault(null, null));
}

[Fact]
Expand Down Expand Up @@ -917,7 +917,7 @@ public void SetAzureSubscriptionAsCurrentSetsCurrent()

Assert.Equal(azureSubscription2.Id, AzureSession.CurrentContext.Subscription.Id);
Assert.Throws<ArgumentException>(() => client.SetSubscriptionAsCurrent("bad", null));
Assert.Throws<ArgumentNullException>(() => client.SetSubscriptionAsCurrent(null, null));
Assert.Throws<ArgumentException>(() => client.SetSubscriptionAsCurrent(null, null));
}

[Fact]
Expand Down Expand Up @@ -1076,6 +1076,73 @@ public void ImportPublishSettingsUsesPassedInEnvironment()
Assert.Equal(7, client.Profile.Subscriptions.Count);
}

[Fact]
public void SelectAzureSubscriptionByIdWorks()
{
MockDataStore dataStore = new MockDataStore();
ProfileClient.DataStore = dataStore;
ProfileClient client = new ProfileClient();

var tempSubscriptions = new List<AzureSubscription>
{
new AzureSubscription
{
Id = new Guid("11111111-1383-4740-8A69-748C5B63ADBA"),
Name = "Same Name Subscription",
Environment = azureEnvironment.Name,
Account = azureAccount.Id,
Properties = new Dictionary<AzureSubscription.Property, string>
{
{ AzureSubscription.Property.Default, "True" }
}
},

new AzureSubscription
{
Id = new Guid("22222222-1383-4740-8A69-748C5B63ADBA"),
Name = "Same Name Subscription",
Environment = azureEnvironment.Name,
Account = azureAccount.Id,
Properties = new Dictionary<AzureSubscription.Property, string>()
},

new AzureSubscription
{
Id = new Guid("33333333-1383-4740-8A69-748C5B63ADBA"),
Name = "Same Name Subscription",
Environment = azureEnvironment.Name,
Account = azureAccount.Id,
Properties = new Dictionary<AzureSubscription.Property, string>()
}
};

client.Profile.Accounts[azureAccount.Id] = azureAccount;
client.AddOrSetEnvironment(azureEnvironment);

foreach (var s in tempSubscriptions)
{
client.AddOrSetSubscription(s);
}

client.SetSubscriptionAsCurrent(tempSubscriptions[0].Name, tempSubscriptions[0].Account);
client.Profile.Save();

Assert.Equal(tempSubscriptions[0].Id, AzureSession.CurrentContext.Subscription.Id);

var cmdlt = new SelectAzureSubscriptionCommand();

cmdlt.CommandRuntime = new MockCommandRuntime();
cmdlt.SubscriptionId = tempSubscriptions[2].Id.ToString();
cmdlt.SetParameterSet("SelectSubscriptionByIdParameterSet");

// Act
cmdlt.InvokeBeginProcessing();
cmdlt.ExecuteCmdlet();
cmdlt.InvokeEndProcessing();

Assert.Equal(tempSubscriptions[2].Id, AzureSession.CurrentContext.Subscription.Id);
}

[Fact]
public void ImportPublishSettingsAddsSecondCertificate()
{
Expand Down
14 changes: 14 additions & 0 deletions src/Common/Commands.Common.Test/Common/ProfileCmdltsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ public void ClearAzureProfileClearsTokenCache()
Assert.Equal(0, tokenCache.ReadItems().Count());
}

[Fact]
public void DeleteCorruptedTokenCache()
{
//setup
string testFileName = @"c:\foobar\TokenCache.dat";
ProfileClient.DataStore.WriteFile(testFileName, new byte[] { 0, 1 });

//Act
ProtectedFileTokenCache tokenCache = new ProtectedFileTokenCache(testFileName);

//Assert
Assert.False(ProfileClient.DataStore.FileExists(testFileName));
}

[Fact]
public void SetAzureSubscriptionAddsSubscriptionWithCertificate()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Commands.Common.Test/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<package id="Microsoft.Data.Services.Client" version="5.6.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.11.10918.1222" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Common" version="1.4.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Common.Dependencies" version="1.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Common" version="1.4.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Common.Dependencies" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.0.0" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,39 @@ public static ProtectedFileTokenCache Instance
// Initializes the cache against a local file.
// If the file is already present, it loads its content in the ADAL cache
private ProtectedFileTokenCache()
{
Initialize(CacheFileName);
}

private void Initialize(string fileName)
{
AfterAccess = AfterAccessNotification;
BeforeAccess = BeforeAccessNotification;
lock (fileLock)
{
if (ProfileClient.DataStore.FileExists(CacheFileName))
if (ProfileClient.DataStore.FileExists(fileName))
{
var existingData = ProfileClient.DataStore.ReadFileAsBytes(CacheFileName);
var existingData = ProfileClient.DataStore.ReadFileAsBytes(fileName);
if (existingData != null)
{
Deserialize(ProtectedData.Unprotect(existingData, null, DataProtectionScope.CurrentUser));
try
{
Deserialize(ProtectedData.Unprotect(existingData, null, DataProtectionScope.CurrentUser));
}
catch (CryptographicException)
{
ProfileClient.DataStore.DeleteFile(fileName);
}
}
}
}
}

public ProtectedFileTokenCache(string cacheFile)
{
Initialize(cacheFile);
}

// Empties the persistent store.
public override void Clear()
{
Expand All @@ -81,7 +98,14 @@ void BeforeAccessNotification(TokenCacheNotificationArgs args)
var existingData = ProfileClient.DataStore.ReadFileAsBytes(CacheFileName);
if (existingData != null)
{
Deserialize(ProtectedData.Unprotect(existingData, null, DataProtectionScope.CurrentUser));
try
{
Deserialize(ProtectedData.Unprotect(existingData, null, DataProtectionScope.CurrentUser));
}
catch (CryptographicException)
{
ProfileClient.DataStore.DeleteFile(CacheFileName);
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Commands.Common/Commands.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@
</Reference>
<Reference Include="Microsoft.WindowsAzure.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Common.1.4.0\lib\net45\Microsoft.WindowsAzure.Common.dll</HintPath>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Common.1.4.1\lib\net45\Microsoft.WindowsAzure.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Common.NetFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Common.1.4.0\lib\net45\Microsoft.WindowsAzure.Common.NetFramework.dll</HintPath>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Common.1.4.1\lib\net45\Microsoft.WindowsAzure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
26 changes: 17 additions & 9 deletions src/Common/Commands.Common/Common/AzurePowerShellClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,24 @@ private void RegisterServiceManagementProviders<T>(AzureContext context) where T
}
}

private void UpdateSubscriptionRegisteredProviders(AzureSubscription subscription, List<string> providers)
private void UpdateSubscriptionRegisteredProviders(AzureSubscription subscription, List<string> providers)
{
if (providers != null && providers.Count > 0)
{
subscription.SetOrAppendProperty(AzureSubscription.Property.RegisteredResourceProviders,
providers.ToArray());
ProfileClient profileClient = new ProfileClient();
profileClient.AddOrSetSubscription(subscription);
profileClient.Profile.Save();
}
     if (providers != null && providers.Count > 0)
     {
         subscription.SetOrAppendProperty(AzureSubscription.Property.RegisteredResourceProviders,
             providers.ToArray());
         try
         {
             ProfileClient profileClient = new ProfileClient();
             profileClient.AddOrSetSubscription(subscription);
             profileClient.Profile.Save();
         }
         catch (KeyNotFoundException)
         {
             // if using a subscription data file, do not write registration to disk
             // long term solution is using -Profile parameter
         }
     }
}
}
}
Loading