diff --git a/.gitignore b/.gitignore index ac45c755c73f..d487996de989 100644 --- a/.gitignore +++ b/.gitignore @@ -192,3 +192,5 @@ UpgradeLog*.htm # Microsoft Fakes FakesAssemblies/ + +.vs/ \ No newline at end of file diff --git a/AzurePowershell.Test.targets b/AzurePowershell.Test.targets index 44bf29123ff1..93506ce9c63c 100644 --- a/AzurePowershell.Test.targets +++ b/AzurePowershell.Test.targets @@ -44,7 +44,7 @@ - + @@ -81,7 +81,7 @@ diff --git a/ChangeLog.md b/ChangeLog.md index 539297984543..a1185a65229a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -35,6 +35,15 @@ * Stop-AzureBatchJob * Stop-AzureBatchJobSchedule * Stop-AzureBatchTask +* Azure Data Factory + * Update SDK reference to 3.0.0 to use API version 2015-09-01 + * Imposes message size limits for all authoring types. Pipelines must be 200 KB or less in size and all others must be 30 KB or less. + * TeradataLinkedService no longer accepts the obsolete properties "database" and "schema". + * Obsolete copy-related properties are no longer returned from the service. +* Azure Sql (ARM) Cmdlets - added the following cmdlets + * Get-AzureSqlServerActiveDirectoryAdministrator + * Set-AzureSqlServerActiveDirectoryAdministrator + * Remove-AzureSqlServerActiveDirectoryAdministrator ## 2015.08.17 version 0.9.7 * Azure Profile cmdlets diff --git a/build.proj b/build.proj index 6a272b56a3e9..9922b99c4b89 100644 --- a/build.proj +++ b/build.proj @@ -20,12 +20,13 @@ true - + + @@ -33,12 +34,22 @@ + + @@ -47,7 +58,7 @@ Targets="Clean" Properties="$(DebugBuildConfig)" ContinueOnError="false" /> - + @@ -74,9 +85,9 @@ - $(MSBuildProjectDirectory)\src\.nuget\NuGet.exe - $(MSBuildProjectDirectory)\restore.config - -ConfigFile "$(NuGetRestoreConfigFile)" + $(MSBuildProjectDirectory)\src\.nuget\NuGet.exe + $(MSBuildProjectDirectory)\restore.config + -ConfigFile "$(NuGetRestoreConfigFile)" + @@ -101,7 +112,8 @@ - + + @@ -113,13 +125,25 @@ + + - + ContinueOnError="false" />--> @@ -153,11 +177,11 @@ Importance="high" Text="You are required to have installed the WiX Toolset at http://wix.codeplex.com/releases/view/115492 (Wix38.msi)" ContinueOnError="false" /> - + ContinueOnError="false" />--> @@ -171,7 +195,13 @@ + + - + - + diff --git a/src/AzurePowershell.sln b/src/AzurePowershell.sln deleted file mode 100644 index afe5a4118fc3..000000000000 --- a/src/AzurePowershell.sln +++ /dev/null @@ -1,635 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8531411A-0137-4E27-9C5E-49E07C245048}" - ProjectSection(SolutionItems) = preProject - local.runsettings = local.runsettings - Local.testsettings = Local.testsettings - Local.x64.testsettings = Local.x64.testsettings - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands", "ServiceManagement\Services\Commands\Commands.csproj", "{CD5AA507-F5EF-473D-855B-84B91A1ABE54}" - ProjectSection(ProjectDependencies) = postProject - {E1F5201D-6067-430E-B303-4E367652991B} = {E1F5201D-6067-430E-B303-4E367652991B} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Test", "ServiceManagement\Services\Commands.Test\Commands.Test.csproj", "{B7FD03F6-98BC-4F54-9A14-0455E579FCD4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.SqlDatabase", "ServiceManagement\Sql\Commands.SqlDatabase\Commands.SqlDatabase.csproj", "{DDF5D225-C9C5-42B7-BDB5-2C3646E479AA}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.SqlDatabase.Test", "ServiceManagement\Sql\Commands.SqlDatabase.Test\Commands.SqlDatabase.Test.csproj", "{37455286-D8A7-4E0C-8B4D-C517D20C641A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Storage", "ServiceManagement\Storage\Commands.Storage\Commands.Storage.csproj", "{08CF7DA7-0392-4A19-B79B-E1FF67CDB81A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Storage.Test", "ServiceManagement\Storage\Commands.Storage.Test\Commands.Storage.Test.csproj", "{D6F470A6-7395-4B8B-9D29-44DF0EC8F624}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ScenarioTest", "Common\Commands.ScenarioTest\Commands.ScenarioTest.csproj", "{A3965B66-5A3E-4B8C-9574-28E5958D4828}" - ProjectSection(ProjectDependencies) = postProject - {CD5AA507-F5EF-473D-855B-84B91A1ABE54} = {CD5AA507-F5EF-473D-855B-84B91A1ABE54} - {DDF5D225-C9C5-42B7-BDB5-2C3646E479AA} = {DDF5D225-C9C5-42B7-BDB5-2C3646E479AA} - {E895BBDA-0B06-46AB-B909-9B97B3ECE47E} = {E895BBDA-0B06-46AB-B909-9B97B3ECE47E} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ServiceManagement", "ServiceManagement\Compute\Commands.ServiceManagement\Commands.ServiceManagement.csproj", "{E1CA72BA-8374-45F6-904D-FD34ECDF5B6F}" - ProjectSection(ProjectDependencies) = postProject - {C60342B1-47D3-4A0E-8081-9B97CE60B7AF} = {C60342B1-47D3-4A0E-8081-9B97CE60B7AF} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ServiceManagement.Test", "ServiceManagement\Compute\Commands.ServiceManagement.Test\Commands.ServiceManagement.Test.csproj", "{58A78F29-8C0C-4A5E-893E-3953C0F29C8A}" - ProjectSection(ProjectDependencies) = postProject - {98B10548-DF97-4FB1-8D82-2A12945D4F21} = {98B10548-DF97-4FB1-8D82-2A12945D4F21} - {08CF7DA7-0392-4A19-B79B-E1FF67CDB81A} = {08CF7DA7-0392-4A19-B79B-E1FF67CDB81A} - {40FEE0BB-FD45-4EFC-85BC-0D602A6892C4} = {40FEE0BB-FD45-4EFC-85BC-0D602A6892C4} - {FDB897BD-FCB4-44A1-8D66-AC99F22EC737} = {FDB897BD-FCB4-44A1-8D66-AC99F22EC737} - {E895BBDA-0B06-46AB-B909-9B97B3ECE47E} = {E895BBDA-0B06-46AB-B909-9B97B3ECE47E} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sync", "ServiceManagement\Compute\Sync\Sync.csproj", "{73820CBC-F4EB-4C5E-B4F0-CC4A93FBF157}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VhdManagement", "ServiceManagement\Compute\VhdManagement\VhdManagement.csproj", "{80496B7B-068A-4A1E-B0BB-4B1FFF3FA616}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Utilities", "ServiceManagement\Services\Commands.Utilities\Commands.Utilities.csproj", "{4900EC4E-8DEB-4412-9108-0BC52F81D457}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Test.Utilities", "ServiceManagement\Services\Commands.Test.Utilities\Commands.Test.Utilities.csproj", "{BC420543-C04E-4BF3-96E1-CD81B823BDD7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Storage.MsTestLib", "ServiceManagement\Storage\Commands.Storage.MsTestLib\Commands.Storage.MsTestLib.csproj", "{CE97967B-7479-43B9-9561-776232AC5D47}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Storage.StorageTestLib", "ServiceManagement\Storage\Commands.Storage.StorageTestLib\Commands.Storage.StorageTestLib.csproj", "{0A513849-2690-4D07-8DE7-0ACE39645D12}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Storage.ScenarioTest", "ServiceManagement\Storage\Commands.Storage.ScenarioTest\Commands.Storage.ScenarioTest.csproj", "{4BC0E3D3-6EDD-43AA-8F15-DCFED8ACC93D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Storage.MsTest2", "ServiceManagement\Storage\Commands.Storage.MsTest2\Commands.Storage.MsTest2.csproj", "{9D5A40CA-5594-4F5C-8230-7ADF7CC0558E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ServiceManagement.PlatformImageRepository", "ServiceManagement\Compute\Commands.ServiceManagement.PlatformImageRepository\Commands.ServiceManagement.PlatformImageRepository.csproj", "{6478FA8B-3801-4863-8591-87F0855D5C82}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ServiceManagement.Preview", "ServiceManagement\Compute\Commands.ServiceManagement.Preview\Commands.ServiceManagement.Preview.csproj", "{E895BBDA-0B06-46AB-B909-9B97B3ECE47E}" - ProjectSection(ProjectDependencies) = postProject - {6478FA8B-3801-4863-8591-87F0855D5C82} = {6478FA8B-3801-4863-8591-87F0855D5C82} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ExpressRoute", "ServiceManagement\ExpressRoute\Commands.ExpressRoute\Commands.ExpressRoute.csproj", "{45C2D687-E0CE-4C97-B731-335834DC2BF2}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Common", "Common\Commands.Common\Commands.Common.csproj", "{5EE72C53-1720-4309-B54B-5FB79703195F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Common.Storage", "Common\Commands.Common.Storage\Commands.Common.Storage.csproj", "{65C3A86A-716D-4E7D-AB67-1DB00B3BF72D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Common.Test", "Common\Commands.Common.Test\Commands.Common.Test.csproj", "{3B48A77B-5956-4A62-9081-92BA04B02B27}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{95C16AED-FD57-42A0-86C3-2CF4300A4817}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Resources", "ResourceManager\Resources\Commands.Resources\Commands.Resources.csproj", "{E1F5201D-6067-430E-B303-4E367652991B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Resources.Test", "ResourceManager\Resources\Commands.Resources.Test\Commands.Resources.Test.csproj", "{4C2FE49A-09E1-4979-AD46-CD64FD04C8F7}" - ProjectSection(ProjectDependencies) = postProject - {D470E50A-9607-48D6-A924-4F9F86502704} = {D470E50A-9607-48D6-A924-4F9F86502704} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.TrafficManager", "ServiceManagement\TrafficManager\Commands.TrafficManager\Commands.TrafficManager.csproj", "{94E96A5C-B5AD-4E10-B13A-3BC16D102AED}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ManagedCache", "ServiceManagement\ManagedCache\Commands.ManagedCache\Commands.ManagedCache.csproj", "{46C06ED8-43D9-41FD-B73B-41547D9C04E1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ManagedCache.Test", "ServiceManagement\ManagedCache\Commands.ManagedCache.Test\Commands.ManagedCache.Test.csproj", "{374D4000-DEDE-4995-9B63-E3B9FE0C4D29}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Profile", "Common\Commands.Profile\Commands.Profile.csproj", "{C60342B1-47D3-4A0E-8081-9B97CE60B7AF}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Automation", "ServiceManagement\Automation\Commands.Automation\Commands.Automation.csproj", "{47CD7E95-5330-4384-ABCE-2C267C57085C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Automation.Test", "ServiceManagement\Automation\Commands.Automation.Test\Commands.Automation.Test.csproj", "{127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.TrafficManager.Test", "ServiceManagement\TrafficManager\Commands.TrafficManager.Test\Commands.TrafficManager.Test.csproj", "{84F99CBD-5B86-4428-B263-135B2F67F512}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.HDInsight.Test", "ServiceManagement\HDInsight\Commands.HDInsight.Test\Commands.HDInsight.Test.csproj", "{7E8D2555-2DDD-4757-974F-D5FFD0647671}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Tags", "ResourceManager\Tags\Commands.Tags\Commands.Tags.csproj", "{2493A8F7-1949-4F29-8D53-9D459046C3B8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ScenarioTests.Common", "Common\Commands.ScenarioTests.Common\Commands.ScenarioTests.Common.csproj", "{C1BDA476-A5CC-4394-914D-48B0EC31A710}" - ProjectSection(ProjectDependencies) = postProject - {CD5AA507-F5EF-473D-855B-84B91A1ABE54} = {CD5AA507-F5EF-473D-855B-84B91A1ABE54} - {E1F5201D-6067-430E-B303-4E367652991B} = {E1F5201D-6067-430E-B303-4E367652991B} - {DDF5D225-C9C5-42B7-BDB5-2C3646E479AA} = {DDF5D225-C9C5-42B7-BDB5-2C3646E479AA} - {98B10548-DF97-4FB1-8D82-2A12945D4F21} = {98B10548-DF97-4FB1-8D82-2A12945D4F21} - {137D404A-865A-43DB-930C-6DA67DA048DF} = {137D404A-865A-43DB-930C-6DA67DA048DF} - {4900EC4E-8DEB-4412-9108-0BC52F81D457} = {4900EC4E-8DEB-4412-9108-0BC52F81D457} - {94E96A5C-B5AD-4E10-B13A-3BC16D102AED} = {94E96A5C-B5AD-4E10-B13A-3BC16D102AED} - {45C2D687-E0CE-4C97-B731-335834DC2BF2} = {45C2D687-E0CE-4C97-B731-335834DC2BF2} - {47CD7E95-5330-4384-ABCE-2C267C57085C} = {47CD7E95-5330-4384-ABCE-2C267C57085C} - {08CF7DA7-0392-4A19-B79B-E1FF67CDB81A} = {08CF7DA7-0392-4A19-B79B-E1FF67CDB81A} - {C60342B1-47D3-4A0E-8081-9B97CE60B7AF} = {C60342B1-47D3-4A0E-8081-9B97CE60B7AF} - {E1CA72BA-8374-45F6-904D-FD34ECDF5B6F} = {E1CA72BA-8374-45F6-904D-FD34ECDF5B6F} - {40FEE0BB-FD45-4EFC-85BC-0D602A6892C4} = {40FEE0BB-FD45-4EFC-85BC-0D602A6892C4} - {46C06ED8-43D9-41FD-B73B-41547D9C04E1} = {46C06ED8-43D9-41FD-B73B-41547D9C04E1} - {2493A8F7-1949-4F29-8D53-9D459046C3B8} = {2493A8F7-1949-4F29-8D53-9D459046C3B8} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Sql", "ResourceManager\Sql\Commands.Sql\Commands.Sql.csproj", "{69ED499E-6F3C-488F-86B8-B74CFDA4D47E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.DataFactories", "ResourceManager\DataFactories\Commands.DataFactories\Commands.DataFactories.csproj", "{9577252E-0A6B-4D61-86E8-95F7F309A987}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.DataFactories.Test", "ResourceManager\DataFactories\Commands.DataFactories.Test\Commands.DataFactories.Test.csproj", "{D4EDAD6F-6A1D-4295-9A88-CD3F69EAD42B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Sql.Test", "ResourceManager\Sql\Commands.Sql.Test\Commands.Sql.Test.csproj", "{56ED8C97-53B9-4DF6-ACB5-7E6800105BF8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RedisCache", "ResourceManager\RedisCache\Commands.RedisCache\Commands.RedisCache.csproj", "{C972E3EF-4461-4758-BA31-93E0947B1253}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RedisCache.Test", "ResourceManager\RedisCache\Commands.RedisCache.Test\Commands.RedisCache.Test.csproj", "{4AE5705F-62CF-461D-B72E-DD9DCD9B3609}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Batch", "ResourceManager\AzureBatch\Commands.Batch\Commands.Batch.csproj", "{D470E50A-9607-48D6-A924-4F9F86502704}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Batch.Test", "ResourceManager\AzureBatch\Commands.Batch.Test\Commands.Batch.Test.csproj", "{F4ABAD68-64A5-4B23-B09C-42559A7524DE}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ServiceManagement.Network", "ServiceManagement\Network\Commands.Network\Commands.ServiceManagement.Network.csproj", "{40FEE0BB-FD45-4EFC-85BC-0D602A6892C4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ServiceManagement.Network.Test", "ServiceManagement\Network\Commands.Network.Test\Commands.ServiceManagement.Network.Test.csproj", "{FDB897BD-FCB4-44A1-8D66-AC99F22EC737}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.KeyVault", "ResourceManager\KeyVault\Commands.KeyVault\Commands.KeyVault.csproj", "{9FFC40CC-A341-4D0C-A25D-DC6B78EF6C94}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.KeyVault.Test", "ResourceManager\KeyVault\Commands.KeyVault.Test\Commands.KeyVault.Test.csproj", "{080B0477-7E52-4455-90AB-23BD13D1B1CE}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RecoveryServices", "ServiceManagement\RecoveryServices\Commands.RecoveryServices\Commands.RecoveryServices.csproj", "{98B10548-DF97-4FB1-8D82-2A12945D4F21}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RecoveryServices.Test", "ServiceManagement\RecoveryServices\Commands.RecoveryServices.Test\Commands.RecoveryServices.Test.csproj", "{A415F75B-EB6A-49A6-934E-5BA71B83D6EB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Dns", "ResourceManager\Dns\Commands.Dns\Commands.Dns.csproj", "{3CAE1B57-FFEC-4945-A6C5-6E5E8DEA4BA9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Dns.Test", "ResourceManager\Dns\Commands.Dns.Test\Commands.Dns.Test.csproj", "{133561EC-99AF-4ADC-AF41-39C4D3AD323B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StorSimple", "ServiceManagement\StorSimple\Commands.StorSimple\Commands.StorSimple.csproj", "{11524D98-6C40-4091-A8E1-86463FEE607C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StorSimple.Test", "ServiceManagement\StorSimple\Commands.StorSimple.Test\Commands.StorSimple.Test.csproj", "{0FA676D5-1349-4086-B33F-65EC2CB7DA41}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StreamAnalytics", "ResourceManager\StreamAnalytics\Commands.StreamAnalytics\Commands.StreamAnalytics.csproj", "{F49A314A-A235-47D3-A654-1EC19ACA366C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StreamAnalytics.Test", "ResourceManager\StreamAnalytics\Commands.StreamAnalytics.Test\Commands.StreamAnalytics.Test.csproj", "{7E6683BE-ECFF-4709-89EB-1325E9E70512}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Insights", "ResourceManager\Insights\Commands.Insights\Commands.Insights.csproj", "{DEA446A1-84E2-46CC-B780-EB4AFDE2460E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Insights.Test", "ResourceManager\Insights\Commands.Insights.Test\Commands.Insights.Test.csproj", "{469F20E0-9D40-41AD-94C3-B47AD15A4C00}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Websites", "ResourceManager\Websites\Commands.Websites\Commands.Websites.csproj", "{80A92297-7C92-456B-8EE7-9FB6CE30149D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ResourceManagement.Automation", "ResourceManager\Automation\Commands.Automation\Commands.ResourceManagement.Automation.csproj", "{90DEF35A-F7FF-40D0-B008-F489A4C092DB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Websites.Test", "ResourceManager\Websites\Commands.Websites.Test\Commands.Websites.Test.csproj", "{13E031E4-8A43-4B87-9D72-D70180C31C11}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RemoteApp", "ServiceManagement\RemoteApp\Commands.RemoteApp\Commands.RemoteApp.csproj", "{492D2AF2-950B-4F2E-8079-8794305313FD}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RemoteApp.Test", "ServiceManagement\RemoteApp\Commands.RemoteApp.Test\Commands.RemoteApp.Test.csproj", "{CA82D500-1940-4068-A076-D7A8AD459FB0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Compute", "ResourceManager\Compute\Commands.Compute\Commands.Compute.csproj", "{52643BD5-6378-49BD-9F6E-DAC9DD8A867B}" - ProjectSection(ProjectDependencies) = postProject - {E1F5201D-6067-430E-B303-4E367652991B} = {E1F5201D-6067-430E-B303-4E367652991B} - {98CFD96B-A6BC-4F15-AE2C-603FC2B58981} = {98CFD96B-A6BC-4F15-AE2C-603FC2B58981} - {E1CA72BA-8374-45F6-904D-FD34ECDF5B6F} = {E1CA72BA-8374-45F6-904D-FD34ECDF5B6F} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Compute.Test", "ResourceManager\Compute\Commands.Compute.Test\Commands.Compute.Test.csproj", "{37C44181-3F1B-4ABD-8089-26DFAB4B6BA8}" - ProjectSection(ProjectDependencies) = postProject - {4C2FE49A-09E1-4979-AD46-CD64FD04C8F7} = {4C2FE49A-09E1-4979-AD46-CD64FD04C8F7} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Network.Test", "ResourceManager\Network\Commands.Network.Test\Commands.Network.Test.csproj", "{A2DF4FE5-46EE-43E2-B246-E5CDDD47B752}" - ProjectSection(ProjectDependencies) = postProject - {98CFD96B-A6BC-4F15-AE2C-603FC2B58981} = {98CFD96B-A6BC-4F15-AE2C-603FC2B58981} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Network", "ResourceManager\Network\Commands.Network\Commands.Network.csproj", "{98CFD96B-A6BC-4F15-AE2C-603FC2B58981}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.TrafficManager2", "ResourceManager\TrafficManager\Commands.TrafficManager2\Commands.TrafficManager2.csproj", "{270CBB5F-BB8A-4E33-B35B-95698E607D97}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.TrafficManager2.Test", "ResourceManager\TrafficManager\Commands.TrafficManager2.Test\Commands.TrafficManager2.Test.csproj", "{5764A3A4-586C-4536-8481-13007CAC111B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ResourceManagement.Automation.Test", "ResourceManager\Automation\Commands.Automation.Test\Commands.ResourceManagement.Automation.Test.csproj", "{59D1B5DC-9175-43EC-90C6-CBA601B3565F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ResourceManager.Cmdlets", "ResourceManager\ResourceManager\Commands.ResourceManager\Cmdlets\Commands.ResourceManager.Cmdlets.csproj", "{8058D403-06E3-4BED-8924-D166CE303961}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ApiManagement", "ResourceManager\ApiManagement\Commands.ApiManagement\Commands.ApiManagement.csproj", "{DC0A9742-DF36-48C9-BD2F-68D01AED6257}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ApiManagement.Test", "ResourceManager\ApiManagement\Commands.ApiManagement.Test\Commands.ApiManagement.Test.csproj", "{BEC9ECE9-A3D6-4B24-A682-1FA890647D9D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Management.Storage", "ResourceManager\Storage\Commands.Management.Storage\Commands.Management.Storage.csproj", "{A50AB133-5C04-4A17-9054-F8343683EC23}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Management.Storage.Test", "ResourceManager\Storage\Commands.Management.Storage.Test\Commands.Management.Storage.Test.csproj", "{7D1D3B56-4EB4-4819-86FD-43330DED8EE7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.OperationalInsights", "ResourceManager\OperationalInsights\Commands.OperationalInsights\Commands.OperationalInsights.csproj", "{5BE35A94-C20F-4659-AA29-9B9AEBCFAF36}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.OperationalInsights.Test", "ResourceManager\OperationalInsights\Commands.OperationalInsights.Test\Commands.OperationalInsights.Test.csproj", "{11387E0A-4DB6-49B8-BDBC-EE020D85D10F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.UsageAggregates", "ResourceManager\Commerce\Commands.UsageAggregates\Commands.UsageAggregates.csproj", "{1A131D3A-EAC4-420C-A1C0-5490ED68EF67}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.UsageAggregates.Test", "ResourceManager\Commerce\Commands.UsageAggregates.Test\Commands.UsageAggregates.Test.csproj", "{F220C306-29A3-4511-8518-A58A55C60D07}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ApiManagement.ServiceManagement", "ResourceManager\ApiManagement\Commands.ApiManagement.ServiceManagement\Commands.ApiManagement.ServiceManagement.csproj", "{ED8BA708-AF42-4C08-9F4E-DAA1037797D5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ApiManagement.ServiceManagement.Test", "ResourceManager\ApiManagement\Commands.SMAPI.Test\Commands.ApiManagement.ServiceManagement.Test.csproj", "{6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.AzureBackup", "ResourceManager\AzureBackup\Commands.AzureBackup\Commands.AzureBackup.csproj", "{6C8D2337-C9D1-4F52-94B3-AB63A19F3453}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.AzureBackup.Test", "ResourceManager\AzureBackup\Commands.AzureBackup.Test\Commands.AzureBackup.Test.csproj", "{678AE95D-2364-47D7-888C-3FFA6D412CC8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HDInsight", "ServiceManagement\HDInsight\Commands.HDInsight\HDInsight.csproj", "{137D404A-865A-43DB-930C-6DA67DA048DF}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.HDInsight", "ResourceManager\HDInsight\Commands.HDInsight\Commands.HDInsight.csproj", "{6B7540C5-8AB3-4011-864B-0BE76F282F9E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.SiteRecovery", "ResourceManager\SiteRecovery\Commands.SiteRecovery\Commands.SiteRecovery.csproj", "{7C879645-31EE-4A78-AD81-5512300FA104}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.SiteRecovery.Test", "ResourceManager\SiteRecovery\Commands.SiteRecovery.Test\Commands.SiteRecovery.Test.csproj", "{6C7D3D81-37AB-445E-8081-78A1FEC0A773}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CD5AA507-F5EF-473D-855B-84B91A1ABE54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CD5AA507-F5EF-473D-855B-84B91A1ABE54}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CD5AA507-F5EF-473D-855B-84B91A1ABE54}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CD5AA507-F5EF-473D-855B-84B91A1ABE54}.Release|Any CPU.Build.0 = Release|Any CPU - {B7FD03F6-98BC-4F54-9A14-0455E579FCD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B7FD03F6-98BC-4F54-9A14-0455E579FCD4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B7FD03F6-98BC-4F54-9A14-0455E579FCD4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B7FD03F6-98BC-4F54-9A14-0455E579FCD4}.Release|Any CPU.Build.0 = Release|Any CPU - {DDF5D225-C9C5-42B7-BDB5-2C3646E479AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DDF5D225-C9C5-42B7-BDB5-2C3646E479AA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DDF5D225-C9C5-42B7-BDB5-2C3646E479AA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DDF5D225-C9C5-42B7-BDB5-2C3646E479AA}.Release|Any CPU.Build.0 = Release|Any CPU - {37455286-D8A7-4E0C-8B4D-C517D20C641A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {37455286-D8A7-4E0C-8B4D-C517D20C641A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {37455286-D8A7-4E0C-8B4D-C517D20C641A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {37455286-D8A7-4E0C-8B4D-C517D20C641A}.Release|Any CPU.Build.0 = Release|Any CPU - {08CF7DA7-0392-4A19-B79B-E1FF67CDB81A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {08CF7DA7-0392-4A19-B79B-E1FF67CDB81A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {08CF7DA7-0392-4A19-B79B-E1FF67CDB81A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {08CF7DA7-0392-4A19-B79B-E1FF67CDB81A}.Release|Any CPU.Build.0 = Release|Any CPU - {D6F470A6-7395-4B8B-9D29-44DF0EC8F624}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D6F470A6-7395-4B8B-9D29-44DF0EC8F624}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D6F470A6-7395-4B8B-9D29-44DF0EC8F624}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D6F470A6-7395-4B8B-9D29-44DF0EC8F624}.Release|Any CPU.Build.0 = Release|Any CPU - {A3965B66-5A3E-4B8C-9574-28E5958D4828}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A3965B66-5A3E-4B8C-9574-28E5958D4828}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A3965B66-5A3E-4B8C-9574-28E5958D4828}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A3965B66-5A3E-4B8C-9574-28E5958D4828}.Release|Any CPU.Build.0 = Release|Any CPU - {E1CA72BA-8374-45F6-904D-FD34ECDF5B6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E1CA72BA-8374-45F6-904D-FD34ECDF5B6F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E1CA72BA-8374-45F6-904D-FD34ECDF5B6F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E1CA72BA-8374-45F6-904D-FD34ECDF5B6F}.Release|Any CPU.Build.0 = Release|Any CPU - {58A78F29-8C0C-4A5E-893E-3953C0F29C8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {58A78F29-8C0C-4A5E-893E-3953C0F29C8A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {58A78F29-8C0C-4A5E-893E-3953C0F29C8A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {58A78F29-8C0C-4A5E-893E-3953C0F29C8A}.Release|Any CPU.Build.0 = Release|Any CPU - {73820CBC-F4EB-4C5E-B4F0-CC4A93FBF157}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {73820CBC-F4EB-4C5E-B4F0-CC4A93FBF157}.Debug|Any CPU.Build.0 = Debug|Any CPU - {73820CBC-F4EB-4C5E-B4F0-CC4A93FBF157}.Release|Any CPU.ActiveCfg = Release|Any CPU - {73820CBC-F4EB-4C5E-B4F0-CC4A93FBF157}.Release|Any CPU.Build.0 = Release|Any CPU - {80496B7B-068A-4A1E-B0BB-4B1FFF3FA616}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {80496B7B-068A-4A1E-B0BB-4B1FFF3FA616}.Debug|Any CPU.Build.0 = Debug|Any CPU - {80496B7B-068A-4A1E-B0BB-4B1FFF3FA616}.Release|Any CPU.ActiveCfg = Release|Any CPU - {80496B7B-068A-4A1E-B0BB-4B1FFF3FA616}.Release|Any CPU.Build.0 = Release|Any CPU - {4900EC4E-8DEB-4412-9108-0BC52F81D457}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4900EC4E-8DEB-4412-9108-0BC52F81D457}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4900EC4E-8DEB-4412-9108-0BC52F81D457}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4900EC4E-8DEB-4412-9108-0BC52F81D457}.Release|Any CPU.Build.0 = Release|Any CPU - {BC420543-C04E-4BF3-96E1-CD81B823BDD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BC420543-C04E-4BF3-96E1-CD81B823BDD7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BC420543-C04E-4BF3-96E1-CD81B823BDD7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BC420543-C04E-4BF3-96E1-CD81B823BDD7}.Release|Any CPU.Build.0 = Release|Any CPU - {CE97967B-7479-43B9-9561-776232AC5D47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CE97967B-7479-43B9-9561-776232AC5D47}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CE97967B-7479-43B9-9561-776232AC5D47}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CE97967B-7479-43B9-9561-776232AC5D47}.Release|Any CPU.Build.0 = Release|Any CPU - {0A513849-2690-4D07-8DE7-0ACE39645D12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0A513849-2690-4D07-8DE7-0ACE39645D12}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0A513849-2690-4D07-8DE7-0ACE39645D12}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0A513849-2690-4D07-8DE7-0ACE39645D12}.Release|Any CPU.Build.0 = Release|Any CPU - {4BC0E3D3-6EDD-43AA-8F15-DCFED8ACC93D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4BC0E3D3-6EDD-43AA-8F15-DCFED8ACC93D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4BC0E3D3-6EDD-43AA-8F15-DCFED8ACC93D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4BC0E3D3-6EDD-43AA-8F15-DCFED8ACC93D}.Release|Any CPU.Build.0 = Release|Any CPU - {9D5A40CA-5594-4F5C-8230-7ADF7CC0558E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9D5A40CA-5594-4F5C-8230-7ADF7CC0558E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9D5A40CA-5594-4F5C-8230-7ADF7CC0558E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9D5A40CA-5594-4F5C-8230-7ADF7CC0558E}.Release|Any CPU.Build.0 = Release|Any CPU - {6478FA8B-3801-4863-8591-87F0855D5C82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6478FA8B-3801-4863-8591-87F0855D5C82}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6478FA8B-3801-4863-8591-87F0855D5C82}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6478FA8B-3801-4863-8591-87F0855D5C82}.Release|Any CPU.Build.0 = Release|Any CPU - {E895BBDA-0B06-46AB-B909-9B97B3ECE47E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E895BBDA-0B06-46AB-B909-9B97B3ECE47E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E895BBDA-0B06-46AB-B909-9B97B3ECE47E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E895BBDA-0B06-46AB-B909-9B97B3ECE47E}.Release|Any CPU.Build.0 = Release|Any CPU - {45C2D687-E0CE-4C97-B731-335834DC2BF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {45C2D687-E0CE-4C97-B731-335834DC2BF2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {45C2D687-E0CE-4C97-B731-335834DC2BF2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {45C2D687-E0CE-4C97-B731-335834DC2BF2}.Release|Any CPU.Build.0 = Release|Any CPU - {5EE72C53-1720-4309-B54B-5FB79703195F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5EE72C53-1720-4309-B54B-5FB79703195F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5EE72C53-1720-4309-B54B-5FB79703195F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5EE72C53-1720-4309-B54B-5FB79703195F}.Release|Any CPU.Build.0 = Release|Any CPU - {65C3A86A-716D-4E7D-AB67-1DB00B3BF72D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {65C3A86A-716D-4E7D-AB67-1DB00B3BF72D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {65C3A86A-716D-4E7D-AB67-1DB00B3BF72D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {65C3A86A-716D-4E7D-AB67-1DB00B3BF72D}.Release|Any CPU.Build.0 = Release|Any CPU - {3B48A77B-5956-4A62-9081-92BA04B02B27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3B48A77B-5956-4A62-9081-92BA04B02B27}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3B48A77B-5956-4A62-9081-92BA04B02B27}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3B48A77B-5956-4A62-9081-92BA04B02B27}.Release|Any CPU.Build.0 = Release|Any CPU - {E1F5201D-6067-430E-B303-4E367652991B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E1F5201D-6067-430E-B303-4E367652991B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E1F5201D-6067-430E-B303-4E367652991B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E1F5201D-6067-430E-B303-4E367652991B}.Release|Any CPU.Build.0 = Release|Any CPU - {4C2FE49A-09E1-4979-AD46-CD64FD04C8F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4C2FE49A-09E1-4979-AD46-CD64FD04C8F7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4C2FE49A-09E1-4979-AD46-CD64FD04C8F7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4C2FE49A-09E1-4979-AD46-CD64FD04C8F7}.Release|Any CPU.Build.0 = Release|Any CPU - {94E96A5C-B5AD-4E10-B13A-3BC16D102AED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {94E96A5C-B5AD-4E10-B13A-3BC16D102AED}.Debug|Any CPU.Build.0 = Debug|Any CPU - {94E96A5C-B5AD-4E10-B13A-3BC16D102AED}.Release|Any CPU.ActiveCfg = Release|Any CPU - {94E96A5C-B5AD-4E10-B13A-3BC16D102AED}.Release|Any CPU.Build.0 = Release|Any CPU - {46C06ED8-43D9-41FD-B73B-41547D9C04E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {46C06ED8-43D9-41FD-B73B-41547D9C04E1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {46C06ED8-43D9-41FD-B73B-41547D9C04E1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {46C06ED8-43D9-41FD-B73B-41547D9C04E1}.Release|Any CPU.Build.0 = Release|Any CPU - {374D4000-DEDE-4995-9B63-E3B9FE0C4D29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {374D4000-DEDE-4995-9B63-E3B9FE0C4D29}.Debug|Any CPU.Build.0 = Debug|Any CPU - {374D4000-DEDE-4995-9B63-E3B9FE0C4D29}.Release|Any CPU.ActiveCfg = Release|Any CPU - {374D4000-DEDE-4995-9B63-E3B9FE0C4D29}.Release|Any CPU.Build.0 = Release|Any CPU - {C60342B1-47D3-4A0E-8081-9B97CE60B7AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C60342B1-47D3-4A0E-8081-9B97CE60B7AF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C60342B1-47D3-4A0E-8081-9B97CE60B7AF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C60342B1-47D3-4A0E-8081-9B97CE60B7AF}.Release|Any CPU.Build.0 = Release|Any CPU - {47CD7E95-5330-4384-ABCE-2C267C57085C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {47CD7E95-5330-4384-ABCE-2C267C57085C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {47CD7E95-5330-4384-ABCE-2C267C57085C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {47CD7E95-5330-4384-ABCE-2C267C57085C}.Release|Any CPU.Build.0 = Release|Any CPU - {127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6}.Release|Any CPU.Build.0 = Release|Any CPU - {84F99CBD-5B86-4428-B263-135B2F67F512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {84F99CBD-5B86-4428-B263-135B2F67F512}.Debug|Any CPU.Build.0 = Debug|Any CPU - {84F99CBD-5B86-4428-B263-135B2F67F512}.Release|Any CPU.ActiveCfg = Release|Any CPU - {84F99CBD-5B86-4428-B263-135B2F67F512}.Release|Any CPU.Build.0 = Release|Any CPU - {7E8D2555-2DDD-4757-974F-D5FFD0647671}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7E8D2555-2DDD-4757-974F-D5FFD0647671}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7E8D2555-2DDD-4757-974F-D5FFD0647671}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7E8D2555-2DDD-4757-974F-D5FFD0647671}.Release|Any CPU.Build.0 = Release|Any CPU - {2493A8F7-1949-4F29-8D53-9D459046C3B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2493A8F7-1949-4F29-8D53-9D459046C3B8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2493A8F7-1949-4F29-8D53-9D459046C3B8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2493A8F7-1949-4F29-8D53-9D459046C3B8}.Release|Any CPU.Build.0 = Release|Any CPU - {C1BDA476-A5CC-4394-914D-48B0EC31A710}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C1BDA476-A5CC-4394-914D-48B0EC31A710}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C1BDA476-A5CC-4394-914D-48B0EC31A710}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C1BDA476-A5CC-4394-914D-48B0EC31A710}.Release|Any CPU.Build.0 = Release|Any CPU - {69ED499E-6F3C-488F-86B8-B74CFDA4D47E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {69ED499E-6F3C-488F-86B8-B74CFDA4D47E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {69ED499E-6F3C-488F-86B8-B74CFDA4D47E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {69ED499E-6F3C-488F-86B8-B74CFDA4D47E}.Release|Any CPU.Build.0 = Release|Any CPU - {9577252E-0A6B-4D61-86E8-95F7F309A987}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9577252E-0A6B-4D61-86E8-95F7F309A987}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9577252E-0A6B-4D61-86E8-95F7F309A987}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9577252E-0A6B-4D61-86E8-95F7F309A987}.Release|Any CPU.Build.0 = Release|Any CPU - {D4EDAD6F-6A1D-4295-9A88-CD3F69EAD42B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D4EDAD6F-6A1D-4295-9A88-CD3F69EAD42B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D4EDAD6F-6A1D-4295-9A88-CD3F69EAD42B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D4EDAD6F-6A1D-4295-9A88-CD3F69EAD42B}.Release|Any CPU.Build.0 = Release|Any CPU - {56ED8C97-53B9-4DF6-ACB5-7E6800105BF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {56ED8C97-53B9-4DF6-ACB5-7E6800105BF8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {56ED8C97-53B9-4DF6-ACB5-7E6800105BF8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {56ED8C97-53B9-4DF6-ACB5-7E6800105BF8}.Release|Any CPU.Build.0 = Release|Any CPU - {C972E3EF-4461-4758-BA31-93E0947B1253}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C972E3EF-4461-4758-BA31-93E0947B1253}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C972E3EF-4461-4758-BA31-93E0947B1253}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C972E3EF-4461-4758-BA31-93E0947B1253}.Release|Any CPU.Build.0 = Release|Any CPU - {4AE5705F-62CF-461D-B72E-DD9DCD9B3609}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4AE5705F-62CF-461D-B72E-DD9DCD9B3609}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4AE5705F-62CF-461D-B72E-DD9DCD9B3609}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4AE5705F-62CF-461D-B72E-DD9DCD9B3609}.Release|Any CPU.Build.0 = Release|Any CPU - {D470E50A-9607-48D6-A924-4F9F86502704}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D470E50A-9607-48D6-A924-4F9F86502704}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D470E50A-9607-48D6-A924-4F9F86502704}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D470E50A-9607-48D6-A924-4F9F86502704}.Release|Any CPU.Build.0 = Release|Any CPU - {F4ABAD68-64A5-4B23-B09C-42559A7524DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F4ABAD68-64A5-4B23-B09C-42559A7524DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F4ABAD68-64A5-4B23-B09C-42559A7524DE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F4ABAD68-64A5-4B23-B09C-42559A7524DE}.Release|Any CPU.Build.0 = Release|Any CPU - {40FEE0BB-FD45-4EFC-85BC-0D602A6892C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {40FEE0BB-FD45-4EFC-85BC-0D602A6892C4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {40FEE0BB-FD45-4EFC-85BC-0D602A6892C4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {40FEE0BB-FD45-4EFC-85BC-0D602A6892C4}.Release|Any CPU.Build.0 = Release|Any CPU - {FDB897BD-FCB4-44A1-8D66-AC99F22EC737}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FDB897BD-FCB4-44A1-8D66-AC99F22EC737}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FDB897BD-FCB4-44A1-8D66-AC99F22EC737}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FDB897BD-FCB4-44A1-8D66-AC99F22EC737}.Release|Any CPU.Build.0 = Release|Any CPU - {9FFC40CC-A341-4D0C-A25D-DC6B78EF6C94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9FFC40CC-A341-4D0C-A25D-DC6B78EF6C94}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9FFC40CC-A341-4D0C-A25D-DC6B78EF6C94}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9FFC40CC-A341-4D0C-A25D-DC6B78EF6C94}.Release|Any CPU.Build.0 = Release|Any CPU - {080B0477-7E52-4455-90AB-23BD13D1B1CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {080B0477-7E52-4455-90AB-23BD13D1B1CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {080B0477-7E52-4455-90AB-23BD13D1B1CE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {080B0477-7E52-4455-90AB-23BD13D1B1CE}.Release|Any CPU.Build.0 = Release|Any CPU - {98B10548-DF97-4FB1-8D82-2A12945D4F21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {98B10548-DF97-4FB1-8D82-2A12945D4F21}.Debug|Any CPU.Build.0 = Debug|Any CPU - {98B10548-DF97-4FB1-8D82-2A12945D4F21}.Release|Any CPU.ActiveCfg = Release|Any CPU - {98B10548-DF97-4FB1-8D82-2A12945D4F21}.Release|Any CPU.Build.0 = Release|Any CPU - {A415F75B-EB6A-49A6-934E-5BA71B83D6EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A415F75B-EB6A-49A6-934E-5BA71B83D6EB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A415F75B-EB6A-49A6-934E-5BA71B83D6EB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A415F75B-EB6A-49A6-934E-5BA71B83D6EB}.Release|Any CPU.Build.0 = Release|Any CPU - {3CAE1B57-FFEC-4945-A6C5-6E5E8DEA4BA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3CAE1B57-FFEC-4945-A6C5-6E5E8DEA4BA9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3CAE1B57-FFEC-4945-A6C5-6E5E8DEA4BA9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3CAE1B57-FFEC-4945-A6C5-6E5E8DEA4BA9}.Release|Any CPU.Build.0 = Release|Any CPU - {133561EC-99AF-4ADC-AF41-39C4D3AD323B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {133561EC-99AF-4ADC-AF41-39C4D3AD323B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {133561EC-99AF-4ADC-AF41-39C4D3AD323B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {133561EC-99AF-4ADC-AF41-39C4D3AD323B}.Release|Any CPU.Build.0 = Release|Any CPU - {11524D98-6C40-4091-A8E1-86463FEE607C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {11524D98-6C40-4091-A8E1-86463FEE607C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {11524D98-6C40-4091-A8E1-86463FEE607C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {11524D98-6C40-4091-A8E1-86463FEE607C}.Release|Any CPU.Build.0 = Release|Any CPU - {0FA676D5-1349-4086-B33F-65EC2CB7DA41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0FA676D5-1349-4086-B33F-65EC2CB7DA41}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0FA676D5-1349-4086-B33F-65EC2CB7DA41}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0FA676D5-1349-4086-B33F-65EC2CB7DA41}.Release|Any CPU.Build.0 = Release|Any CPU - {F49A314A-A235-47D3-A654-1EC19ACA366C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F49A314A-A235-47D3-A654-1EC19ACA366C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F49A314A-A235-47D3-A654-1EC19ACA366C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F49A314A-A235-47D3-A654-1EC19ACA366C}.Release|Any CPU.Build.0 = Release|Any CPU - {7E6683BE-ECFF-4709-89EB-1325E9E70512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7E6683BE-ECFF-4709-89EB-1325E9E70512}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7E6683BE-ECFF-4709-89EB-1325E9E70512}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7E6683BE-ECFF-4709-89EB-1325E9E70512}.Release|Any CPU.Build.0 = Release|Any CPU - {DEA446A1-84E2-46CC-B780-EB4AFDE2460E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DEA446A1-84E2-46CC-B780-EB4AFDE2460E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DEA446A1-84E2-46CC-B780-EB4AFDE2460E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DEA446A1-84E2-46CC-B780-EB4AFDE2460E}.Release|Any CPU.Build.0 = Release|Any CPU - {469F20E0-9D40-41AD-94C3-B47AD15A4C00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {469F20E0-9D40-41AD-94C3-B47AD15A4C00}.Debug|Any CPU.Build.0 = Debug|Any CPU - {469F20E0-9D40-41AD-94C3-B47AD15A4C00}.Release|Any CPU.ActiveCfg = Release|Any CPU - {469F20E0-9D40-41AD-94C3-B47AD15A4C00}.Release|Any CPU.Build.0 = Release|Any CPU - {80A92297-7C92-456B-8EE7-9FB6CE30149D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {80A92297-7C92-456B-8EE7-9FB6CE30149D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {80A92297-7C92-456B-8EE7-9FB6CE30149D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {80A92297-7C92-456B-8EE7-9FB6CE30149D}.Release|Any CPU.Build.0 = Release|Any CPU - {90DEF35A-F7FF-40D0-B008-F489A4C092DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {90DEF35A-F7FF-40D0-B008-F489A4C092DB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {90DEF35A-F7FF-40D0-B008-F489A4C092DB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {90DEF35A-F7FF-40D0-B008-F489A4C092DB}.Release|Any CPU.Build.0 = Release|Any CPU - {13E031E4-8A43-4B87-9D72-D70180C31C11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {13E031E4-8A43-4B87-9D72-D70180C31C11}.Debug|Any CPU.Build.0 = Debug|Any CPU - {13E031E4-8A43-4B87-9D72-D70180C31C11}.Release|Any CPU.ActiveCfg = Release|Any CPU - {13E031E4-8A43-4B87-9D72-D70180C31C11}.Release|Any CPU.Build.0 = Release|Any CPU - {492D2AF2-950B-4F2E-8079-8794305313FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {492D2AF2-950B-4F2E-8079-8794305313FD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {492D2AF2-950B-4F2E-8079-8794305313FD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {492D2AF2-950B-4F2E-8079-8794305313FD}.Release|Any CPU.Build.0 = Release|Any CPU - {CA82D500-1940-4068-A076-D7A8AD459FB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CA82D500-1940-4068-A076-D7A8AD459FB0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CA82D500-1940-4068-A076-D7A8AD459FB0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CA82D500-1940-4068-A076-D7A8AD459FB0}.Release|Any CPU.Build.0 = Release|Any CPU - {52643BD5-6378-49BD-9F6E-DAC9DD8A867B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {52643BD5-6378-49BD-9F6E-DAC9DD8A867B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {52643BD5-6378-49BD-9F6E-DAC9DD8A867B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {52643BD5-6378-49BD-9F6E-DAC9DD8A867B}.Release|Any CPU.Build.0 = Release|Any CPU - {37C44181-3F1B-4ABD-8089-26DFAB4B6BA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {37C44181-3F1B-4ABD-8089-26DFAB4B6BA8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {37C44181-3F1B-4ABD-8089-26DFAB4B6BA8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {37C44181-3F1B-4ABD-8089-26DFAB4B6BA8}.Release|Any CPU.Build.0 = Release|Any CPU - {A2DF4FE5-46EE-43E2-B246-E5CDDD47B752}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A2DF4FE5-46EE-43E2-B246-E5CDDD47B752}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A2DF4FE5-46EE-43E2-B246-E5CDDD47B752}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A2DF4FE5-46EE-43E2-B246-E5CDDD47B752}.Release|Any CPU.Build.0 = Release|Any CPU - {98CFD96B-A6BC-4F15-AE2C-603FC2B58981}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {98CFD96B-A6BC-4F15-AE2C-603FC2B58981}.Debug|Any CPU.Build.0 = Debug|Any CPU - {98CFD96B-A6BC-4F15-AE2C-603FC2B58981}.Release|Any CPU.ActiveCfg = Release|Any CPU - {98CFD96B-A6BC-4F15-AE2C-603FC2B58981}.Release|Any CPU.Build.0 = Release|Any CPU - {270CBB5F-BB8A-4E33-B35B-95698E607D97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {270CBB5F-BB8A-4E33-B35B-95698E607D97}.Debug|Any CPU.Build.0 = Debug|Any CPU - {270CBB5F-BB8A-4E33-B35B-95698E607D97}.Release|Any CPU.ActiveCfg = Release|Any CPU - {270CBB5F-BB8A-4E33-B35B-95698E607D97}.Release|Any CPU.Build.0 = Release|Any CPU - {5764A3A4-586C-4536-8481-13007CAC111B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5764A3A4-586C-4536-8481-13007CAC111B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5764A3A4-586C-4536-8481-13007CAC111B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5764A3A4-586C-4536-8481-13007CAC111B}.Release|Any CPU.Build.0 = Release|Any CPU - {59D1B5DC-9175-43EC-90C6-CBA601B3565F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {59D1B5DC-9175-43EC-90C6-CBA601B3565F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {59D1B5DC-9175-43EC-90C6-CBA601B3565F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {59D1B5DC-9175-43EC-90C6-CBA601B3565F}.Release|Any CPU.Build.0 = Release|Any CPU - {8058D403-06E3-4BED-8924-D166CE303961}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8058D403-06E3-4BED-8924-D166CE303961}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8058D403-06E3-4BED-8924-D166CE303961}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8058D403-06E3-4BED-8924-D166CE303961}.Release|Any CPU.Build.0 = Release|Any CPU - {DC0A9742-DF36-48C9-BD2F-68D01AED6257}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DC0A9742-DF36-48C9-BD2F-68D01AED6257}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DC0A9742-DF36-48C9-BD2F-68D01AED6257}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DC0A9742-DF36-48C9-BD2F-68D01AED6257}.Release|Any CPU.Build.0 = Release|Any CPU - {BEC9ECE9-A3D6-4B24-A682-1FA890647D9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BEC9ECE9-A3D6-4B24-A682-1FA890647D9D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BEC9ECE9-A3D6-4B24-A682-1FA890647D9D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BEC9ECE9-A3D6-4B24-A682-1FA890647D9D}.Release|Any CPU.Build.0 = Release|Any CPU - {A50AB133-5C04-4A17-9054-F8343683EC23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A50AB133-5C04-4A17-9054-F8343683EC23}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A50AB133-5C04-4A17-9054-F8343683EC23}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A50AB133-5C04-4A17-9054-F8343683EC23}.Release|Any CPU.Build.0 = Release|Any CPU - {7D1D3B56-4EB4-4819-86FD-43330DED8EE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7D1D3B56-4EB4-4819-86FD-43330DED8EE7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7D1D3B56-4EB4-4819-86FD-43330DED8EE7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7D1D3B56-4EB4-4819-86FD-43330DED8EE7}.Release|Any CPU.Build.0 = Release|Any CPU - {5BE35A94-C20F-4659-AA29-9B9AEBCFAF36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5BE35A94-C20F-4659-AA29-9B9AEBCFAF36}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5BE35A94-C20F-4659-AA29-9B9AEBCFAF36}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5BE35A94-C20F-4659-AA29-9B9AEBCFAF36}.Release|Any CPU.Build.0 = Release|Any CPU - {11387E0A-4DB6-49B8-BDBC-EE020D85D10F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {11387E0A-4DB6-49B8-BDBC-EE020D85D10F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {11387E0A-4DB6-49B8-BDBC-EE020D85D10F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {11387E0A-4DB6-49B8-BDBC-EE020D85D10F}.Release|Any CPU.Build.0 = Release|Any CPU - {1A131D3A-EAC4-420C-A1C0-5490ED68EF67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1A131D3A-EAC4-420C-A1C0-5490ED68EF67}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1A131D3A-EAC4-420C-A1C0-5490ED68EF67}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1A131D3A-EAC4-420C-A1C0-5490ED68EF67}.Release|Any CPU.Build.0 = Release|Any CPU - {F220C306-29A3-4511-8518-A58A55C60D07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F220C306-29A3-4511-8518-A58A55C60D07}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F220C306-29A3-4511-8518-A58A55C60D07}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F220C306-29A3-4511-8518-A58A55C60D07}.Release|Any CPU.Build.0 = Release|Any CPU - {ED8BA708-AF42-4C08-9F4E-DAA1037797D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ED8BA708-AF42-4C08-9F4E-DAA1037797D5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ED8BA708-AF42-4C08-9F4E-DAA1037797D5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ED8BA708-AF42-4C08-9F4E-DAA1037797D5}.Release|Any CPU.Build.0 = Release|Any CPU - {6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}.Release|Any CPU.Build.0 = Release|Any CPU - {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Release|Any CPU.Build.0 = Release|Any CPU - {678AE95D-2364-47D7-888C-3FFA6D412CC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {678AE95D-2364-47D7-888C-3FFA6D412CC8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {678AE95D-2364-47D7-888C-3FFA6D412CC8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {678AE95D-2364-47D7-888C-3FFA6D412CC8}.Release|Any CPU.Build.0 = Release|Any CPU - {137D404A-865A-43DB-930C-6DA67DA048DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {137D404A-865A-43DB-930C-6DA67DA048DF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {137D404A-865A-43DB-930C-6DA67DA048DF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {137D404A-865A-43DB-930C-6DA67DA048DF}.Release|Any CPU.Build.0 = Release|Any CPU - {6B7540C5-8AB3-4011-864B-0BE76F282F9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6B7540C5-8AB3-4011-864B-0BE76F282F9E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6B7540C5-8AB3-4011-864B-0BE76F282F9E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6B7540C5-8AB3-4011-864B-0BE76F282F9E}.Release|Any CPU.Build.0 = Release|Any CPU - {7C879645-31EE-4A78-AD81-5512300FA104}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7C879645-31EE-4A78-AD81-5512300FA104}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7C879645-31EE-4A78-AD81-5512300FA104}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7C879645-31EE-4A78-AD81-5512300FA104}.Release|Any CPU.Build.0 = Release|Any CPU - {6C7D3D81-37AB-445E-8081-78A1FEC0A773}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6C7D3D81-37AB-445E-8081-78A1FEC0A773}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6C7D3D81-37AB-445E-8081-78A1FEC0A773}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6C7D3D81-37AB-445E-8081-78A1FEC0A773}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {B7FD03F6-98BC-4F54-9A14-0455E579FCD4} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {37455286-D8A7-4E0C-8B4D-C517D20C641A} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {D6F470A6-7395-4B8B-9D29-44DF0EC8F624} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {A3965B66-5A3E-4B8C-9574-28E5958D4828} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {58A78F29-8C0C-4A5E-893E-3953C0F29C8A} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {BC420543-C04E-4BF3-96E1-CD81B823BDD7} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {CE97967B-7479-43B9-9561-776232AC5D47} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {0A513849-2690-4D07-8DE7-0ACE39645D12} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {4BC0E3D3-6EDD-43AA-8F15-DCFED8ACC93D} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {9D5A40CA-5594-4F5C-8230-7ADF7CC0558E} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {3B48A77B-5956-4A62-9081-92BA04B02B27} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {4C2FE49A-09E1-4979-AD46-CD64FD04C8F7} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {374D4000-DEDE-4995-9B63-E3B9FE0C4D29} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {84F99CBD-5B86-4428-B263-135B2F67F512} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {7E8D2555-2DDD-4757-974F-D5FFD0647671} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {C1BDA476-A5CC-4394-914D-48B0EC31A710} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {D4EDAD6F-6A1D-4295-9A88-CD3F69EAD42B} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {56ED8C97-53B9-4DF6-ACB5-7E6800105BF8} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {4AE5705F-62CF-461D-B72E-DD9DCD9B3609} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {F4ABAD68-64A5-4B23-B09C-42559A7524DE} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {FDB897BD-FCB4-44A1-8D66-AC99F22EC737} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {080B0477-7E52-4455-90AB-23BD13D1B1CE} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {A415F75B-EB6A-49A6-934E-5BA71B83D6EB} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {133561EC-99AF-4ADC-AF41-39C4D3AD323B} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {0FA676D5-1349-4086-B33F-65EC2CB7DA41} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {7E6683BE-ECFF-4709-89EB-1325E9E70512} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {469F20E0-9D40-41AD-94C3-B47AD15A4C00} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {13E031E4-8A43-4B87-9D72-D70180C31C11} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {CA82D500-1940-4068-A076-D7A8AD459FB0} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {37C44181-3F1B-4ABD-8089-26DFAB4B6BA8} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {A2DF4FE5-46EE-43E2-B246-E5CDDD47B752} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {5764A3A4-586C-4536-8481-13007CAC111B} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {59D1B5DC-9175-43EC-90C6-CBA601B3565F} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {BEC9ECE9-A3D6-4B24-A682-1FA890647D9D} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {7D1D3B56-4EB4-4819-86FD-43330DED8EE7} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {11387E0A-4DB6-49B8-BDBC-EE020D85D10F} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {F220C306-29A3-4511-8518-A58A55C60D07} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {678AE95D-2364-47D7-888C-3FFA6D412CC8} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - {6C7D3D81-37AB-445E-8081-78A1FEC0A773} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} - EndGlobalSection -EndGlobal diff --git a/src/Common/Commands.Common/AzurePSCmdlet.cs b/src/Common/AzurePSCmdlet.cs similarity index 51% rename from src/Common/Commands.Common/AzurePSCmdlet.cs rename to src/Common/AzurePSCmdlet.cs index 6e3cfc3d0bae..a9311b6eb1f2 100644 --- a/src/Common/Commands.Common/AzurePSCmdlet.cs +++ b/src/Common/AzurePSCmdlet.cs @@ -1,4 +1,4 @@ -// ---------------------------------------------------------------------------------- +// ---------------------------------------------------------------------------------- // // Copyright Microsoft Corporation // Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,200 +12,99 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using System; using System.Collections.Concurrent; +using System.Diagnostics; +using System.Management.Automation; +using System.Net.Http.Headers; +using System.Reflection; using Microsoft.Azure.Common.Authentication; using Microsoft.Azure.Common.Authentication.Models; -using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.Properties; -using System; -using System.Diagnostics; -using System.IO; -using System.Management.Automation; namespace Microsoft.WindowsAzure.Commands.Utilities.Common { - public abstract class AzurePSCmdlet : PSCmdlet + /// + /// Represents base class for all Azure cmdlets. + /// + public abstract class AzurePSCmdlet : PSCmdlet, IDisposable { - private readonly ConcurrentQueue _debugMessages = new ConcurrentQueue(); + private readonly ConcurrentQueue _debugMessages; + private RecordingTracingInterceptor _httpTracingInterceptor; - private DebugStreamTraceListener _adalListener; - protected static AzureProfile _currentProfile = null; - [Parameter(Mandatory = false, HelpMessage = "In-memory profile.")] - public AzureProfile Profile { get; set; } + private DebugStreamTraceListener _adalListener; /// - /// Sets the current profile - the profile used when no Profile is explicitly passed in. Should be used only by - /// Profile cmdlets and tests that need to set up a particular profile + /// Gets the PowerShell module name used for user agent header. + /// By default uses "Azurepowershell" /// - public static AzureProfile CurrentProfile - { - private get - { - if (_currentProfile == null) - { - _currentProfile = InitializeDefaultProfile(); - SetTokenCacheForProfile(_currentProfile); - } - - return _currentProfile; - } - - set - { - SetTokenCacheForProfile(value); - _currentProfile = value; - } - } - - protected static TokenCache DefaultDiskTokenCache { get; set; } - - protected static TokenCache DefaultMemoryTokenCache { get; set; } - - static AzurePSCmdlet() - { - if (!TestMockSupport.RunningMocked) - { - AzureSession.ClientFactory.AddAction(new RPRegistrationAction()); - } - - AzureSession.ClientFactory.UserAgents.Add(AzurePowerShell.UserAgentValue); - if (!TestMockSupport.RunningMocked) - { - InitializeTokenCaches(); - AzureSession.DataStore = new DiskDataStore(); - SetTokenCacheForProfile(CurrentProfile); - } - } + protected virtual string ModuleName { get { return "AzurePowershell"; } } /// - /// Create the default profile, based on the default profile path + /// Gets PowerShell module version used for user agent header. /// - /// The default profile, serialized from the default location on disk - protected static AzureProfile InitializeDefaultProfile() - { - if (!string.IsNullOrEmpty(AzureSession.ProfileDirectory) && !string.IsNullOrEmpty(AzureSession.ProfileFile)) - { - try - { - GeneralUtilities.EnsureDefaultProfileDirectoryExists(); - return new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); - } - catch - { - // swallow exceptions in creating the profile from disk - } - } - - return new AzureProfile(); - } + protected string ModuleVersion { get { return Assembly.GetCallingAssembly().GetName().Version.ToString(); } } /// - /// Get the context for the current profile before BeginProcessing is called + /// Gets the default Azure context. /// - /// The context for the current profile - protected AzureContext GetCurrentContext() - { - if (Profile != null) - { - return Profile.Context; - } - - return CurrentProfile.Context; - } - - protected static void InitializeTokenCaches() - { - DefaultMemoryTokenCache = TokenCache.DefaultShared; - if (!string.IsNullOrWhiteSpace(AzureSession.ProfileDirectory) && - !string.IsNullOrWhiteSpace(AzureSession.TokenCacheFile)) - { - GeneralUtilities.EnsureDefaultProfileDirectoryExists(); - DefaultDiskTokenCache = new ProtectedFileTokenCache(Path.Combine(AzureSession.ProfileDirectory, AzureSession.TokenCacheFile)); - } - else - { - DefaultDiskTokenCache = DefaultMemoryTokenCache; - } - } + protected abstract AzureContext DefaultContext { get; } /// - /// Update the token cache when setting the profile + /// Initializes AzurePSCmdlet properties. /// - /// - protected static void SetTokenCacheForProfile(AzureProfile profile) + public AzurePSCmdlet() { - var defaultProfilePath = Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile); - if (string.Equals(profile.ProfilePath, defaultProfilePath, StringComparison.OrdinalIgnoreCase)) - { - AzureSession.TokenCache = DefaultDiskTokenCache; - } - else - { - AzureSession.TokenCache = DefaultMemoryTokenCache; - } + _debugMessages = new ConcurrentQueue(); } /// - /// Cmdlet begin process. Write to logs, setup Http Tracing and initialize profile + /// Cmdlet begin process. Write to logs, setup Http Tracing and initialize profile and adds user agent. /// protected override void BeginProcessing() { - InitializeProfile(); if (string.IsNullOrEmpty(ParameterSetName)) { - WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithoutParameterSetLog, this.GetType().Name)); + WriteDebugWithTimestamp(string.Format("{0} begin processing without ParameterSet.", this.GetType().Name)); } else { - WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithParameterSetLog, this.GetType().Name, ParameterSetName)); + WriteDebugWithTimestamp(string.Format("{0} begin processing with ParameterSet '{1}'.", this.GetType().Name, ParameterSetName)); } - if (Profile != null && Profile.Context != null && Profile.Context.Account != null && Profile.Context.Account.Id != null) + if (DefaultContext != null && DefaultContext.Account != null && DefaultContext.Account.Id != null) { - WriteDebugWithTimestamp(string.Format("using account id '{0}'...", Profile.Context.Account.Id)); + WriteDebugWithTimestamp(string.Format("using account id '{0}'...", DefaultContext.Account.Id)); } - _httpTracingInterceptor = _httpTracingInterceptor?? new RecordingTracingInterceptor(_debugMessages); - _adalListener = _adalListener?? new DebugStreamTraceListener(_debugMessages); + _httpTracingInterceptor = _httpTracingInterceptor ?? new RecordingTracingInterceptor(_debugMessages); + _adalListener = _adalListener ?? new DebugStreamTraceListener(_debugMessages); RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor); DebugStreamTraceListener.AddAdalTracing(_adalListener); - base.BeginProcessing(); - } - - /// - /// Ensure that there is a profile for the command - /// - protected virtual void InitializeProfile() - { - if (Profile == null) - { - Profile = AzurePSCmdlet.CurrentProfile; - } + ProductInfoHeaderValue userAgentValue = new ProductInfoHeaderValue( + ModuleName, string.Format("v{0}", ModuleVersion)); + AzureSession.ClientFactory.UserAgents.Add(userAgentValue); - SetTokenCacheForProfile(Profile); + base.BeginProcessing(); } /// - /// End processing. Flush messages in tracing interceptor and save profile. + /// End processing. Flush messages in tracing interceptor and save profile and removes user agent. /// protected override void EndProcessing() { - string message = string.Format(Resources.EndProcessingLog, this.GetType().Name); + string message = string.Format("{0} end processing.", this.GetType().Name); WriteDebugWithTimestamp(message); RecordingTracingInterceptor.RemoveFromContext(_httpTracingInterceptor); DebugStreamTraceListener.RemoveAdalTracing(_adalListener); FlushDebugMessages(); - base.EndProcessing(); - } + AzureSession.ClientFactory.UserAgents.RemoveAll(u => u.Product.Name == ModuleName); - public bool HasCurrentSubscription - { - get { return Profile.Context.Subscription != null; } + base.EndProcessing(); } protected string CurrentPath() @@ -223,49 +122,49 @@ protected bool IsVerbose() return verbose; } - public new void WriteError(ErrorRecord errorRecord) + protected new void WriteError(ErrorRecord errorRecord) { FlushDebugMessages(); base.WriteError(errorRecord); } - public new void WriteObject(object sendToPipeline) + protected new void WriteObject(object sendToPipeline) { FlushDebugMessages(); base.WriteObject(sendToPipeline); } - public new void WriteObject(object sendToPipeline, bool enumerateCollection) + protected new void WriteObject(object sendToPipeline, bool enumerateCollection) { FlushDebugMessages(); base.WriteObject(sendToPipeline, enumerateCollection); } - public new void WriteVerbose(string text) + protected new void WriteVerbose(string text) { FlushDebugMessages(); base.WriteVerbose(text); } - public new void WriteWarning(string text) + protected new void WriteWarning(string text) { FlushDebugMessages(); base.WriteWarning(text); } - public new void WriteCommandDetail(string text) + protected new void WriteCommandDetail(string text) { FlushDebugMessages(); base.WriteCommandDetail(text); } - public new void WriteProgress(ProgressRecord progressRecord) + protected new void WriteProgress(ProgressRecord progressRecord) { FlushDebugMessages(); base.WriteProgress(progressRecord); } - public new void WriteDebug(string text) + protected new void WriteDebug(string text) { FlushDebugMessages(); base.WriteDebug(text); @@ -326,24 +225,6 @@ protected void SafeWriteOutputPSObject(string typeName, params object[] args) WriteObject(customObject); } - public virtual void ExecuteCmdlet() - { - // Do nothing. - } - - protected override void ProcessRecord() - { - try - { - base.ProcessRecord(); - ExecuteCmdlet(); - } - catch (Exception ex) - { - WriteExceptionError(ex); - } - } - private void FlushDebugMessages() { string message; @@ -371,5 +252,16 @@ protected void ConfirmAction(bool force, string actionMessage, string processMes } } } + + protected virtual void Dispose(bool disposing) + { + _adalListener.Dispose(); + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } } } diff --git a/src/Common/Commands.Common.Storage/Commands.Common.Storage.csproj b/src/Common/Commands.Common.Storage/Commands.Common.Storage.csproj index 2cac1e4b0bbd..27f3ae6ca2e1 100644 --- a/src/Common/Commands.Common.Storage/Commands.Common.Storage.csproj +++ b/src/Common/Commands.Common.Storage/Commands.Common.Storage.csproj @@ -58,7 +58,7 @@ False - ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.3-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll False @@ -142,6 +142,8 @@ + + False ..\..\packages\System.Spatial.5.6.4\lib\net40\System.Spatial.dll @@ -166,12 +168,6 @@ - - - {5ee72c53-1720-4309-b54b-5fb79703195f} - Commands.Common - - ResXFileCodeGenerator diff --git a/src/Common/Commands.Common.Storage/Properties/AssemblyInfo.cs b/src/Common/Commands.Common.Storage/Properties/AssemblyInfo.cs index e03883414b6c..6f37a649d717 100644 --- a/src/Common/Commands.Common.Storage/Properties/AssemblyInfo.cs +++ b/src/Common/Commands.Common.Storage/Properties/AssemblyInfo.cs @@ -17,12 +17,12 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("Microsoft Azure Powershell - Common Storage Library")] -[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)] -[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)] -[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Microsoft Azure Powershell")] +[assembly: AssemblyCopyright("Copyright © Microsoft")] [assembly: ComVisible(false)] [assembly: CLSCompliant(false)] [assembly: Guid("c565107e-98a9-4703-85cd-a7efc3d8da7b")] -[assembly: AssemblyVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyVersion)] -[assembly: AssemblyFileVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyFileVersion)] +[assembly: AssemblyVersion("0.9.8")] +[assembly: AssemblyFileVersion("0.9.8")] diff --git a/src/Common/Commands.Common.Storage/Properties/Resources.Designer.cs b/src/Common/Commands.Common.Storage/Properties/Resources.Designer.cs index 1dd6d72ee692..45193722a648 100644 --- a/src/Common/Commands.Common.Storage/Properties/Resources.Designer.cs +++ b/src/Common/Commands.Common.Storage/Properties/Resources.Designer.cs @@ -1,17 +1,17 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34014 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace Microsoft.WindowsAzure.Commands.Common.Storage.Properties -{ - - +namespace Microsoft.WindowsAzure.Commands.Common.Storage.Properties { + using System; + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -69,6 +69,15 @@ internal static string AnonymousAccountName { } } + /// + /// Looks up a localized string similar to Blob with the name {0} already exists in the account.. + /// + internal static string BlobAlreadyExistsInTheAccount { + get { + return ResourceManager.GetString("BlobAlreadyExistsInTheAccount", resourceCulture); + } + } + /// /// Looks up a localized string similar to [SasToken]. /// diff --git a/src/Common/Commands.Common.Storage/Properties/Resources.resx b/src/Common/Commands.Common.Storage/Properties/Resources.resx index 429223e5b11b..fa4b4d6931a7 100644 --- a/src/Common/Commands.Common.Storage/Properties/Resources.resx +++ b/src/Common/Commands.Common.Storage/Properties/Resources.resx @@ -120,6 +120,9 @@ [Anonymous] + + Blob with the name {0} already exists in the account. + [SasToken] diff --git a/src/Common/Commands.Common.Storage/StorageClientWrapper.cs b/src/Common/Commands.Common.Storage/StorageClientWrapper.cs index f9fa33cc92a4..0ea15bd0a581 100644 --- a/src/Common/Commands.Common.Storage/StorageClientWrapper.cs +++ b/src/Common/Commands.Common.Storage/StorageClientWrapper.cs @@ -17,6 +17,7 @@ namespace Microsoft.WindowsAzure.Commands.Common.Storage using System; using System.Globalization; using System.IO; + using Properties; using Microsoft.WindowsAzure.Commands.Utilities.Common; using Microsoft.WindowsAzure.Management.Storage; using Microsoft.WindowsAzure.Management.Storage.Models; @@ -58,7 +59,7 @@ public Uri UploadFileToBlob(BlobUploadParameters parameters) StorageAccountGetResponse storageService = StorageManagementClient.StorageAccounts.Get(parameters.StorageName); Uri blobEndpointUri = storageService.StorageAccount.Properties.Endpoints[0]; return UploadFile(parameters.StorageName, - GeneralUtilities.CreateHttpsEndpoint(blobEndpointUri.ToString()), + StorageUtilities.CreateHttpsEndpoint(blobEndpointUri.ToString()), storageKey, parameters); } @@ -97,7 +98,7 @@ private Uri UploadFile(string storageName, Uri blobEndpointUri, string storageKe else { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, - Commands.Common.Properties.Resources.BlobAlreadyExistsInTheAccount, blobName)); + Resources.BlobAlreadyExistsInTheAccount, blobName)); } } diff --git a/src/Common/Commands.Common.Storage/StorageUtilities.cs b/src/Common/Commands.Common.Storage/StorageUtilities.cs index 5fd0a134abe9..7d5b0aaad69c 100644 --- a/src/Common/Commands.Common.Storage/StorageUtilities.cs +++ b/src/Common/Commands.Common.Storage/StorageUtilities.cs @@ -11,6 +11,21 @@ namespace Microsoft.WindowsAzure.Commands.Common.Storage public class StorageUtilities { + /// + /// Creates https endpoint from the given endpoint. + /// + /// The endpoint uri. + /// The https endpoint uri. + public static Uri CreateHttpsEndpoint(string endpointUri) + { + UriBuilder builder = new UriBuilder(endpointUri) { Scheme = "https" }; + string endpoint = builder.Uri.GetComponents( + UriComponents.AbsoluteUri & ~UriComponents.Port, + UriFormat.UriEscaped); + + return new Uri(endpoint); + } + public static CloudStorageAccount GenerateCloudStorageAccount(StorageManagementClient storageClient, string accountName) { var storageServiceResponse = storageClient.StorageAccounts.Get(accountName); @@ -23,18 +38,18 @@ public static CloudStorageAccount GenerateCloudStorageAccount(StorageManagementC if (storageServiceResponse.StorageAccount.Properties.Endpoints.Count >= 4) { - fileEndpoint = GeneralUtilities.CreateHttpsEndpoint(storageServiceResponse.StorageAccount.Properties.Endpoints[3].ToString()); + fileEndpoint = StorageUtilities.CreateHttpsEndpoint(storageServiceResponse.StorageAccount.Properties.Endpoints[3].ToString()); } if (storageServiceResponse.StorageAccount.Properties.Endpoints.Count >= 3) { - tableEndpoint = GeneralUtilities.CreateHttpsEndpoint(storageServiceResponse.StorageAccount.Properties.Endpoints[2].ToString()); - queueEndpoint = GeneralUtilities.CreateHttpsEndpoint(storageServiceResponse.StorageAccount.Properties.Endpoints[1].ToString()); + tableEndpoint = StorageUtilities.CreateHttpsEndpoint(storageServiceResponse.StorageAccount.Properties.Endpoints[2].ToString()); + queueEndpoint = StorageUtilities.CreateHttpsEndpoint(storageServiceResponse.StorageAccount.Properties.Endpoints[1].ToString()); } if (storageServiceResponse.StorageAccount.Properties.Endpoints.Count >= 1) { - blobEndpoint = GeneralUtilities.CreateHttpsEndpoint(storageServiceResponse.StorageAccount.Properties.Endpoints[0].ToString()); + blobEndpoint = StorageUtilities.CreateHttpsEndpoint(storageServiceResponse.StorageAccount.Properties.Endpoints[0].ToString()); } return new CloudStorageAccount( diff --git a/src/Common/Commands.Common.Storage/WindowsAzureSubscriptionExtensions.cs b/src/Common/Commands.Common.Storage/WindowsAzureSubscriptionExtensions.cs index 0ba9d67a5da3..4e0ef2ac9230 100644 --- a/src/Common/Commands.Common.Storage/WindowsAzureSubscriptionExtensions.cs +++ b/src/Common/Commands.Common.Storage/WindowsAzureSubscriptionExtensions.cs @@ -27,7 +27,7 @@ public static class WindowsAzureSubscriptionExtensions { private static Dictionary storageAccountCache = new Dictionary(); - public static CloudStorageAccount GetCloudStorageAccount(this AzureSubscription subscription, AzureProfile profile) + public static CloudStorageAccount GetCloudStorageAccount(this AzureSubscription subscription, AzureSMProfile profile) { if (subscription == null) { diff --git a/src/Common/Commands.Common.Storage/packages.config b/src/Common/Commands.Common.Storage/packages.config index f2ebb79ce6b4..fbc0120719d7 100644 --- a/src/Common/Commands.Common.Storage/packages.config +++ b/src/Common/Commands.Common.Storage/packages.config @@ -2,7 +2,7 @@ - + diff --git a/src/Common/Commands.Common.Test/Commands.Common.Test.csproj b/src/Common/Commands.Common.Test/Commands.Common.Test.csproj index 04be930b6358..6a2767629833 100644 --- a/src/Common/Commands.Common.Test/Commands.Common.Test.csproj +++ b/src/Common/Commands.Common.Test/Commands.Common.Test.csproj @@ -1,6 +1,6 @@  - + Debug @@ -16,7 +16,7 @@ ..\..\ true {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 773c4563 + 9ff8fb41 true @@ -58,17 +58,21 @@ False - ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.3-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll ..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll + + ..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll + True + False ..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll - ..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5687.28567-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll + ..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5715.36130-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll True @@ -160,13 +164,18 @@ - False ..\..\packages\xunit.1.9.2\lib\net20\xunit.dll + True + + + ..\..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll + True + @@ -179,17 +188,15 @@ - - - True True Resources.resx + @@ -201,10 +208,6 @@ {5ee72c53-1720-4309-b54b-5fb79703195f} Commands.Common - - {c60342b1-47d3-4a0e-8081-9b97ce60b7af} - Commands.Profile - {c1bda476-a5cc-4394-914d-48b0ec31a710} Commands.ScenarioTests.Common @@ -310,6 +313,6 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/Common/Commands.Common.Test/Common/MockSubsciptionFactory.cs b/src/Common/Commands.Common.Test/Common/MockSubsciptionFactory.cs index adc1287b3625..34cf4fde13ce 100644 --- a/src/Common/Commands.Common.Test/Common/MockSubsciptionFactory.cs +++ b/src/Common/Commands.Common.Test/Common/MockSubsciptionFactory.cs @@ -31,12 +31,12 @@ public void AddAction(Azure.Common.Authentication.Models.IClientAction action) throw new NotImplementedException(); } - public TClient CreateClient(Azure.Common.Authentication.Models.AzureProfile profile, Azure.Common.Authentication.Models.AzureSubscription subscription, Azure.Common.Authentication.Models.AzureEnvironment.Endpoint endpoint) where TClient : Hyak.Common.ServiceClient + public TClient CreateClient(Azure.Common.Authentication.Models.AzureSMProfile profile, Azure.Common.Authentication.Models.AzureSubscription subscription, Azure.Common.Authentication.Models.AzureEnvironment.Endpoint endpoint) where TClient : Hyak.Common.ServiceClient { throw new NotImplementedException(); } - public TClient CreateClient(Azure.Common.Authentication.Models.AzureProfile profile, Azure.Common.Authentication.Models.AzureEnvironment.Endpoint endpoint) where TClient : Hyak.Common.ServiceClient + public TClient CreateClient(Azure.Common.Authentication.Models.AzureSMProfile profile, Azure.Common.Authentication.Models.AzureEnvironment.Endpoint endpoint) where TClient : Hyak.Common.ServiceClient { throw new NotImplementedException(); } diff --git a/src/Common/Commands.Common.Test/Common/TestingTracingInterceptor.cs b/src/Common/Commands.Common.Test/Common/PSTestTracingInterceptor.cs similarity index 84% rename from src/Common/Commands.Common.Test/Common/TestingTracingInterceptor.cs rename to src/Common/Commands.Common.Test/Common/PSTestTracingInterceptor.cs index a928026e562d..738c1799805e 100644 --- a/src/Common/Commands.Common.Test/Common/TestingTracingInterceptor.cs +++ b/src/Common/Commands.Common.Test/Common/PSTestTracingInterceptor.cs @@ -24,9 +24,9 @@ namespace Microsoft.WindowsAzure.Commands.Common.Test.Common { - public class TestingTracingInterceptor : ICloudTracingInterceptor + public class PSTestTracingInterceptor : ICloudTracingInterceptor { - private TestingTracingInterceptor() + private PSTestTracingInterceptor() { #if DEBUG if (Debug.Listeners.Count < 1) @@ -82,7 +82,6 @@ public void ReceiveResponse(string invocationId, HttpResponseMessage response) public void Error(string invocationId, Exception ex) { - Write("{0} - Error: {1}", invocationId, ex); } public void Exit(string invocationId, object result) @@ -90,27 +89,27 @@ public void Exit(string invocationId, object result) Write("{0} - Exited method with result: {1}", invocationId, result); } - static TestingTracingInterceptor() + static PSTestTracingInterceptor() { - TestingTracingInterceptor.Singleton = new TestingTracingInterceptor(); + PSTestTracingInterceptor.Singleton = new PSTestTracingInterceptor(); } public static void AddToContext() { try { - TracingAdapter.RemoveTracingInterceptor(TestingTracingInterceptor.Singleton); + TracingAdapter.RemoveTracingInterceptor(PSTestTracingInterceptor.Singleton); } catch { } - TracingAdapter.AddTracingInterceptor(TestingTracingInterceptor.Singleton); + TracingAdapter.AddTracingInterceptor(PSTestTracingInterceptor.Singleton); } - static TestingTracingInterceptor Singleton + static PSTestTracingInterceptor Singleton { get; set; } } -} +} \ No newline at end of file diff --git a/src/Common/Commands.Common.Test/Common/ProfileClientTests.cs b/src/Common/Commands.Common.Test/Common/ProfileClientTests.cs new file mode 100644 index 000000000000..0d007aacc5c1 --- /dev/null +++ b/src/Common/Commands.Common.Test/Common/ProfileClientTests.cs @@ -0,0 +1,1688 @@ +// ---------------------------------------------------------------------------------- +// +// 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 Microsoft.Azure.Common.Authentication; +using Microsoft.Azure.Common.Authentication.Models; +using Microsoft.Azure.Subscriptions.Models; +using Microsoft.WindowsAzure.Commands.Common.Test.Mocks; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using Xunit; +using CSMSubscription = Microsoft.Azure.Subscriptions.Models.Subscription; +using RDFESubscription = Microsoft.WindowsAzure.Subscriptions.Models.SubscriptionListOperationResponse.Subscription; + +namespace Common.Authentication.Test +{ + public class ProfileClientTests + { + private string oldProfileData; + private string oldProfileDataBadSubscription; + private string oldProfileDataCorruptedFile; + private string oldProfileDataPath; + private string oldProfileDataPathError; + private string newProfileDataPath; + private string defaultSubscription = "06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F"; + private string dummyCertificate = "MIIKJAIBAzCCCeQGCSqGSIb3DQEHAaCCCdUEggnRMIIJzTCCBe4GCSqGSIb3DQEHAaCCBd8EggXbMIIF1zCCBdMGCyqGSIb3DQEMCgECoIIE7jCCBOowHAYKKoZIhvcNAQwBAzAOBAjilB4DFutYJwICB9AEggTItMCor/6dq+ynHyoo82U2N8bT9fBn57xuvF4zTtZdl503n+q48ZE5SLcUFoeAZkrYoCiyPn4ayVA4pfAHou5I2XEG1B4YF46hD0Bz0igWRSrsVigdoYP98BGGaMgl43d9AQGeV8iJ3d3In/TxMGjHUYzZwoIg1jE7xhQ8dMr2Xenw8pLrxl8FybI1isyxzAUjFE7E/Znv9DYi83VNwjC1uPg8q16PzXUQ/smFVzoZMtvmp8MxPrnI/gHqcS5g7SnnisTLmJcjqdLVywBZqiMo1ALs90EEgc7qgbim9lxGczUh+SI9cj2m5w9XMmXro4XJNJTLFG26DDOVMPfMSr9ij9P4rmxckVK7nHrGhQpshrLr37dF5KGFo6mh79VUadbwn/a4rXjfX9gXm5N/ZS8wq3U4/4Pl7t5N+bwB5izt8JG4aMhX6M6jshNrpe/gZHI9u6jNAo1yRxNfBdoxA7P2sZdlHO4CYTc9zZcZqTgH2QjRLTelIDn17PEQL9L4rEzqhT322WMzNnSMH9TCu3D5l2RuO6hsHl0JK4saiq3s04kkYoLXF9i+ovS0xSmu0zxemnFAGB1q1mlwoWoD06zlXEjHM2Q3T2b8ip1tK6/GFpU8Qs5BOUDanBOCqVLWlyvM/ilXUyN9cyLRMKM1sgEmn5ue0wsZlflU6egqChF8qjSJzq/34FgTjPazvkXkXv0e2vBz5+qzeC/1R8xySdFoehglny42VTkCRH4BzhoXf+MrfrC6tW85WCTKOj8SiTSzYXRragIwfG8RyLViOzdIW9pEAJF3UOloKOGGL1NREAnRPgxm9UVxD1oUj+pqYkPRRXcHuEnbiYEqE8Dgwk6GaSVOZ4CKjKAcapOwwW8bTxHgFOCrwgZhxIFXQhIZVoH8NphqN2WWwIUPa1gsc3uPwVXecgt8y8S01QEYCCFo9dT5sBS0rAOXMTOnSudWSHvz7c36IJSG2KyJwW3YO2UopIQ1V14MBZQhwUyddUILeuOy50u1j2eVOV3XESHO99oNP9FfalmgZw19LQDqX8S861x1w+GuU/NG//LZ0aXXaw1IhddIMZlpZVTADMunXIJbd0OiunfblXFwGZ33M1y/wGvFAZ6ofOuZv6vM0kmtufg3AHl/Vg+jzLOp1bYbKx4f7FHoYAerV88EA/ELXr2NTOLwwRYdk0cLWk4VY2lCLs8lcyoIUrcOS/+af8oX8dgJo9qkx2AiKp6AgYAWwrdpolOH7sMLmtu1rrthoMesExLz6xpUq/rYrWQJuyXWUmwbdxpDYFP8spqcW3KdbroNWhPEvM0tdocSK6lPWNnFMgqbb2qJJqjyV87LBZPEpHI8TPraofE7h4NWjXx/OqA6/dF1t3RvrvYqyC7kvrnaJ2LWfQI/88K9s7LAVvfDIbxWtIadrGXlo4gbtbQDSFzjve123DngBJkXqpzqRoL7mdpFvsgpg0upIKQ1fIbtaksC115g8BGBOzwGlo0Y3f4+ob6++OkePHoLkGhLahCMyDmGV1mxFz3ZUkXyxmfPSeynwXe/N8TxeZ2ixLZMF3sa61CpFsuHfEmVEetFxP5t3rrO5ZIbE87KVtvl6jCr8JQ3h81TZJBaeu8iiNC0MVspJpNQ/irYFElTMYHRMBMGCSqGSIb3DQEJFTEGBAQBAAAAMFsGCSqGSIb3DQEJFDFOHkwAewA0ADgANQBFADQAOQBCADYALQBFAEUARQA4AC0ANAA3ADUAQgAtADgAOQAwAEQALQA5ADcAQQA3ADYARgAyADQANgBEADkAMwB9MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAG8AZgB0AHcAYQByAGUAIABLAGUAeQAgAFMAdABvAHIAYQBnAGUAIABQAHIAbwB2AGkAZABlAHIwggPXBgkqhkiG9w0BBwagggPIMIIDxAIBADCCA70GCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECG9kWMFPd2j2AgIH0ICCA5AUBLyrnhFVIYZKNWVLOWn0nfwmhADWS2FA3LGyGirb/lgpPcolLiQwGnXih0xxESn1CsZcWDpXiUvAfjQF1kxKHyCIUQBkrKQliYIT+RErliVuAY/vv1YW2Zj+bPUtTZKXUDzIPjNgb43+uxvf/wu+gGhAV/dV5oIWLjFhC1u4+Gp/LA5C6j60NtBXG7barSflAWTSOjGt2IIb5mBrUw+GkrhoYOqA+HYG40j2fkmkWpMCkImzcxxEM65ZElGUt7H1QY+GSRAxt7icA5ka9L+A0UM8a1SCFhbBK6Voo0IAkBZctJ6I7h4znhoHtqMDYYzraaYDVAK4SPdwOUMUyYdai0QwOYSL3frwVzC/ZHvCJkRmOsQXj9U44OGoXXrJ4rWIQIkcxFO3rEC3alI9lV5h5w73DWQRjex8Nz214B1yBRdlkoC/HQpgJ6IwFfEyJOn/lGgqkRPbgntTKSjNQZr5Ot60Z1SUYmmcMTpB8jRg+hy0LbWmx+79q9ERUnLO4yrtcXjQza12/FwAdpJOwbFrXMZb3QcuhQfn9aDF9/iNRkhTdxDmumS/C5gjZSYBzTugGDWsyS1hqws7LaYfcs6aWWRafqxt68cpNy4FaNXZ3XwXRVzuH+brnGvnWXRqhzwCbeGxEKDCEPxO9hO8NVrndsGlGfTZmxfTkKnPyRPD6vk4BG0Rc5BniyrmhnaZgSq0M04MeoAjp1s6S8CcIG73H5KkmoqQwSiKUbY3aA15nxqYhQj6L83WK5dPnVlmaV/xOeqkggzsdkaa+eQfA1e5RR27Gkyr5Rl20PQUR6J/sIGWIVCSSaqD2kxmDTODEORsF7jhL4YXZr96hqvNWtyNncxrqvjPsaFi/P2JFxjfZ8wmnF1HDsVW4W/i8cdRTyEz7Go4kzoRvSvC2sCPRAMa3D+o341r7L0hBlCnFfMU5Le8jatMKsw+Nk1TeOc4Cvc+w3gczSKrlhJnPtJjVZ67kKe8Ror8mKOP6afSr27avEizUYvJcCpKztUM59ukEbM2chEb2rrFPWxnB67KaLF825pRm+6Nl3mx0jaPDgK2ToydGfuVBA+9TSpnuV26imsd+K2yL2nwrdvBJPE/t2lPzVIR0hnf4AJ8/9BR0vTGmxiWwy8VMxrS3PyouLPZMXAgdT6ddRVwmewNjTe5g/tciGazIW+nROgg6fsgyObMp7keONMvtFMrJQLa2oKarGkwNzAfMAcGBSsOAwIaBBQXFDnqplMX7OuyknHK7B+HA/N8tAQUsL21+IY37DPL968vhVzqz09W/so="; + private RDFESubscription rdfeSubscription1; + private RDFESubscription rdfeSubscription2; + private CSMSubscription csmSubscription1; + private CSMSubscription csmSubscription1withDuplicateId; + private CSMSubscription csmSubscription2; + private AzureSubscription azureSubscription1; + private AzureSubscription azureSubscription2; + private AzureSubscription azureSubscription3withoutUser; + private AzureEnvironment azureEnvironment; + private AzureAccount azureAccount; + private TenantIdDescription commonTenant; + private TenantIdDescription guestTenant; + private RDFESubscription guestRdfeSubscription; + private CSMSubscription guestCsmSubscription; + private AzureSMProfile currentProfile; + + public ProfileClientTests() + { + SetMockData(); + currentProfile = new AzureSMProfile(); + } + + [Fact] + public void ProfileMigratesOldData() + { + MemoryDataStore dataStore = new MemoryDataStore(); + dataStore.VirtualStore[oldProfileDataPath] = oldProfileData; + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + Assert.False(dataStore.FileExists(oldProfileDataPath)); + Assert.True(dataStore.FileExists(newProfileDataPath)); + } + + [Fact] + public void NewProfileFromCertificateWithNullsThrowsArgumentNullException() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + AzureSMProfile newProfile = new AzureSMProfile(); + ProfileClient client1 = new ProfileClient(newProfile); + Assert.Throws(() => + client1.InitializeProfile(null, Guid.NewGuid(), new X509Certificate2(), "foo")); + Assert.Throws(() => + client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"], Guid.NewGuid(), null, "foo")); + } + + [Fact] + public void NewProfileFromCertificateReturnsProfile() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + AzureSMProfile newProfile = new AzureSMProfile(); + ProfileClient client1 = new ProfileClient(newProfile); + var subscriptionId = Guid.NewGuid(); + var certificate = new X509Certificate2(Convert.FromBase64String(dummyCertificate)); + + client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"], + subscriptionId, certificate, null); + + Assert.Equal("AzureCloud", newProfile.DefaultSubscription.Environment); + Assert.Equal(subscriptionId, newProfile.DefaultSubscription.Id); + Assert.Equal(certificate.Thumbprint, newProfile.DefaultSubscription.Account); + Assert.False(newProfile.DefaultSubscription.Properties.ContainsKey(AzureSubscription.Property.StorageAccount)); + } + + [Fact] + public void NewProfileFromAdCredentialsWithNullsThrowsArgumentNullException() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + AzureSMProfile newProfile = new AzureSMProfile(); + ProfileClient client1 = new ProfileClient(newProfile); + Assert.Throws(() => + client1.InitializeProfile(null, Guid.NewGuid(), new AzureAccount(), null, "foo")); + Assert.Throws(() => + client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"], Guid.NewGuid(), (AzureAccount)null, null, "foo")); + } + + [Fact] + public void NewProfileFromADReturnsProfile() + { + SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new List()); + rdfeSubscription2.ActiveDirectoryTenantId = "123"; + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + AzureSMProfile newProfile = new AzureSMProfile(); + ProfileClient client1 = new ProfileClient(newProfile); + var newAccount = new AzureAccount { Id = "foo" }; + newAccount.Properties[AzureAccount.Property.Tenants] = "123"; + + client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"], + new Guid(rdfeSubscription2.SubscriptionId), newAccount, null, null); + + Assert.Equal("AzureCloud", newProfile.DefaultSubscription.Environment); + Assert.Equal(new Guid(rdfeSubscription2.SubscriptionId), newProfile.DefaultSubscription.Id); + Assert.Equal(newAccount.Id, newProfile.DefaultSubscription.Account); + Assert.False(newProfile.DefaultSubscription.Properties.ContainsKey(AzureSubscription.Property.StorageAccount)); + } + + [Fact] + public void NewProfileWithAccessTokenReturnsProfile() + { + //SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1 }.ToList()); + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + AzureSMProfile newProfile = new AzureSMProfile(); + ProfileClient client1 = new ProfileClient(newProfile); + + client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"], + new Guid(csmSubscription1.SubscriptionId), "accessToken", "accountId", null); + + Assert.Equal("AzureCloud", newProfile.DefaultSubscription.Environment); + Assert.Equal(new Guid(csmSubscription1.SubscriptionId), newProfile.DefaultSubscription.Id); + Assert.Equal("accountId", newProfile.DefaultSubscription.Account); + Assert.Equal(AzureAccount.AccountType.AccessToken, newProfile.DefaultContext.Account.Type); + Assert.Equal("accessToken", newProfile.DefaultContext.Account.Properties[AzureAccount.Property.AccessToken]); + Assert.False(newProfile.DefaultSubscription.Properties.ContainsKey(AzureSubscription.Property.StorageAccount)); + } + + [Fact] + public void NewProfileFromADWithMismatchSubscriptionThrows() + { + SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1 }.ToList()); + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + AzureSMProfile newProfile = new AzureSMProfile(); + ProfileClient client1 = new ProfileClient(newProfile); + var newAccount = new AzureAccount { Id = "foo" }; + newAccount.Properties[AzureAccount.Property.Tenants] = "123"; + + Assert.Throws(() => client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"], + Guid.NewGuid(), newAccount, null, null)); + } + + [Fact] + public void ProfileMigratesOldDataOnce() + { + MemoryDataStore dataStore = new MemoryDataStore(); + dataStore.VirtualStore[oldProfileDataPath] = oldProfileData; + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client1 = new ProfileClient(currentProfile); + + Assert.False(dataStore.FileExists(oldProfileDataPath)); + Assert.True(dataStore.FileExists(newProfileDataPath)); + + ProfileClient client2 = new ProfileClient(currentProfile); + + Assert.False(dataStore.FileExists(oldProfileDataPath)); + Assert.True(dataStore.FileExists(newProfileDataPath)); + } + + [Fact] + public void ProfileMigratesAccountsAndDefaultSubscriptions() + { + MemoryDataStore dataStore = new MemoryDataStore(); + dataStore.VirtualStore[oldProfileDataPath] = oldProfileData; + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + // Verify Environment migration + Assert.Equal(4, client.Profile.Environments.Count); + Assert.Equal("Current", client.Profile.Environments["Current"].Name); + Assert.Equal("Dogfood", client.Profile.Environments["Dogfood"].Name); + Assert.Equal("https://login.windows-ppe.net/", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.AdTenant]); + Assert.Equal("https://management.core.windows.net/", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId]); + Assert.Equal("https://df.gallery.azure-test.net", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.Gallery]); + Assert.Equal("https://windows.azure-test.net", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.ManagementPortalUrl]); + Assert.Equal("https://auxnext.windows.azure-test.net/publishsettings/index", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.PublishSettingsFileUrl]); + 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"))); + Assert.True(client.Profile.Subscriptions.ContainsKey(new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F"))); + Assert.Equal("Test 2", client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")].Name); + Assert.True(client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")].IsPropertySet(AzureSubscription.Property.Default)); + Assert.Equal("test@mail.com", client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")].Account); + Assert.Equal("Dogfood", client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")].Environment); + Assert.Equal("123", client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")].Properties[AzureSubscription.Property.Tenants]); + Assert.True(client.Profile.Subscriptions.ContainsKey(new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f"))); + Assert.Equal("Test 3", client.Profile.Subscriptions[new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")].Name); + Assert.False(client.Profile.Subscriptions[new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")].IsPropertySet(AzureSubscription.Property.Default)); + Assert.Equal("test@mail.com", client.Profile.Subscriptions[new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")].Account); + Assert.Equal("72f988bf-86f1-41af-91ab-2d7cd011db47", client.Profile.Subscriptions[new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")].Properties[AzureSubscription.Property.Tenants]); + Assert.Equal(EnvironmentName.AzureCloud, client.Profile.Subscriptions[new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")].Environment); + Assert.Equal(EnvironmentName.AzureChinaCloud, client.Profile.Subscriptions[new Guid("c14d7dc5-ed4d-4346-a02f-9f1bcf78fb66")].Environment); + + // Verify accounts + Assert.Equal(2, client.Profile.Accounts.Count); + Assert.Equal("test@mail.com", client.Profile.Accounts["test@mail.com"].Id); + Assert.Equal(AzureAccount.AccountType.User, client.Profile.Accounts["test@mail.com"].Type); + Assert.True(client.Profile.Accounts["test@mail.com"].GetPropertyAsArray(AzureAccount.Property.Subscriptions) + .Contains(new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F").ToString())); + Assert.True(client.Profile.Accounts["test@mail.com"].GetPropertyAsArray(AzureAccount.Property.Subscriptions) + .Contains(new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f").ToString())); + Assert.True(client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E09"].GetPropertyAsArray(AzureAccount.Property.Subscriptions) + .Contains(new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f").ToString())); + Assert.True(client.Profile.Accounts["test@mail.com"].GetPropertyAsArray(AzureAccount.Property.Tenants) + .Contains("72f988bf-86f1-41af-91ab-2d7cd011db47")); + Assert.True(client.Profile.Accounts["test@mail.com"].GetPropertyAsArray(AzureAccount.Property.Tenants) + .Contains("123")); + Assert.Equal("3AF24D48B97730E5C4C9CCB12397B5E046F79E09", client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E09"].Id); + Assert.Equal(AzureAccount.AccountType.Certificate, client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E09"].Type); + Assert.Equal(0, client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E09"].GetPropertyAsArray(AzureAccount.Property.Tenants).Length); + Assert.Equal(2, client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E09"].GetPropertyAsArray(AzureAccount.Property.Subscriptions).Length); + } + + [Fact] + public void ProfileMigratesAccountsSkipsBadOnesAndBacksUpFile() + { + MemoryDataStore dataStore = new MemoryDataStore(); + dataStore.VirtualStore[oldProfileDataPath] = oldProfileDataBadSubscription; + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + // 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"))); + Assert.Equal("Test Bad Management Endpoint", client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")].Name); + Assert.Equal(EnvironmentName.AzureCloud, client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")].Environment); + Assert.Equal("Test Null Management Endpoint", client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2ADFF")].Name); + Assert.Equal(EnvironmentName.AzureCloud, client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2ADFF")].Environment); + + 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); + Assert.Equal(AzureAccount.AccountType.User, client.Profile.Accounts["test@mail.com"].Type); + Assert.True(client.Profile.Accounts["test@mail.com"].GetPropertyAsArray(AzureAccount.Property.Subscriptions) + .Contains(new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F").ToString())); + Assert.True(client.Profile.Accounts["test@mail.com"].GetPropertyAsArray(AzureAccount.Property.Subscriptions) + .Contains(new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f").ToString())); + Assert.True(client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E99"].GetPropertyAsArray(AzureAccount.Property.Subscriptions) + .Contains(new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f").ToString())); + Assert.True(client.Profile.Accounts["test@mail.com"].GetPropertyAsArray(AzureAccount.Property.Tenants) + .Contains("72f988bf-86f1-41af-91ab-2d7cd011db47")); + Assert.False(client.Profile.Accounts["test@mail.com"].GetPropertyAsArray(AzureAccount.Property.Tenants) + .Contains("123")); + Assert.Equal("3AF24D48B97730E5C4C9CCB12397B5E046F79E99", client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E99"].Id); + Assert.Equal(AzureAccount.AccountType.Certificate, client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E99"].Type); + Assert.Equal(0, client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E99"].GetPropertyAsArray(AzureAccount.Property.Tenants).Length); + Assert.Equal(1, client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E99"].GetPropertyAsArray(AzureAccount.Property.Subscriptions).Length); + + // Verify backup file + Assert.True(dataStore.FileExists(oldProfileDataPathError)); + Assert.False(dataStore.FileExists(oldProfileDataPath)); + Assert.Equal(oldProfileDataBadSubscription, dataStore.ReadFileAsText(oldProfileDataPathError)); + } + + [Fact] + public void ProfileMigratesCorruptedFileAndCreatedBackup() + { + MemoryDataStore dataStore = new MemoryDataStore(); + dataStore.VirtualStore[oldProfileDataPath] = oldProfileDataCorruptedFile; + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + // 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); + + // Verify backup file + Assert.True(dataStore.FileExists(oldProfileDataPathError)); + Assert.False(dataStore.FileExists(oldProfileDataPath)); + Assert.Equal(oldProfileDataCorruptedFile, dataStore.ReadFileAsText(oldProfileDataPathError)); + } + + [Fact] + public void AddAzureAccountReturnsAccountWithAllSubscriptionsInRdfeMode() + { + SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1 }.ToList()); + MemoryDataStore dataStore = new MemoryDataStore(); + dataStore.VirtualStore[oldProfileDataPath] = oldProfileData; + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + var account = client.AddAccountAndLoadSubscriptions(new AzureAccount { Id = "test", Type = AzureAccount.AccountType.User }, AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], null); + + Assert.Equal("test", account.Id); + Assert.Equal(2, account.GetSubscriptions(client.Profile).Count); + Assert.True(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId))); + Assert.True(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(rdfeSubscription2.SubscriptionId))); + Assert.False(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(csmSubscription1.SubscriptionId))); + } + + [Fact] + public void AddAzureAccountReturnsAccountWithAllSubscriptionsInCsmMode() + { + SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1 }.ToList()); + MemoryDataStore dataStore = new MemoryDataStore(); + dataStore.VirtualStore[oldProfileDataPath] = oldProfileData; + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + var account = client.AddAccountAndLoadSubscriptions( + new AzureAccount + { + Id = "test", + Type = AzureAccount.AccountType.User + }, + AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], + null); + + Assert.Equal("test", account.Id); + Assert.Equal(2, account.GetSubscriptions(client.Profile).Count); + Assert.True(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId))); + Assert.True(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(rdfeSubscription2.SubscriptionId))); + Assert.False(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(csmSubscription1.SubscriptionId))); + } + + /// + /// Verify that if a user has a different identity in one tenantId, the identity is not added if it has no + /// access to subscriptions + /// + [Fact] + public void AddAzureAccountWithImpersonatedGuestWithNoSubscriptions() + { + SetMocks(new[] { rdfeSubscription1 }.ToList(), + new List(), + new[] { commonTenant, guestTenant }.ToList(), + (userAccount, environment, tenant) => + { + var token = new MockAccessToken + { + UserId = tenant == commonTenant.TenantId ? userAccount.Id : "UserB", + AccessToken = "def", + LoginType = LoginType.OrgId + }; + userAccount.Id = token.UserId; + return token; + }); + MemoryDataStore dataStore = new MemoryDataStore(); + dataStore.VirtualStore[oldProfileDataPath] = oldProfileData; + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + var account = client.AddAccountAndLoadSubscriptions(new AzureAccount { Id = "UserA", Type = AzureAccount.AccountType.User }, AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], null); + + Assert.Equal("UserA", account.Id); + Assert.Equal(1, account.GetSubscriptions(client.Profile).Count); + var subrdfe1 = account.GetSubscriptions(client.Profile).FirstOrDefault(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId)); + var userA = client.GetAccount("UserA"); + Assert.Throws(() => client.GetAccount("UserB")); + Assert.NotNull(userA); + Assert.Contains(rdfeSubscription1.SubscriptionId, userA.GetPropertyAsArray(AzureAccount.Property.Subscriptions), StringComparer.OrdinalIgnoreCase); + Assert.NotNull(subrdfe1); + Assert.Equal("UserA", subrdfe1.Account); + } + + /// + /// Verify that multiple accounts can be added if a user has different identities in different domains, linked to the same login + /// Verify that subscriptions with admin access for all accounts are added + /// + [Fact] + public void AddAzureAccountWithImpersonatedGuestWithSubscriptions() + { + SetMocks(new[] { rdfeSubscription1, guestRdfeSubscription }.ToList(), + new List(), + new[] { commonTenant, guestTenant }.ToList(), + (userAccount, environment, tenant) => + { + var token = new MockAccessToken + { + UserId = tenant == commonTenant.TenantId ? userAccount.Id : "UserB", + AccessToken = "def", + LoginType = LoginType.OrgId + }; + userAccount.Id = token.UserId; + return token; + }); + MemoryDataStore dataStore = new MemoryDataStore(); + dataStore.VirtualStore[oldProfileDataPath] = oldProfileData; + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + var account = client.AddAccountAndLoadSubscriptions(new AzureAccount { Id = "UserA", Type = AzureAccount.AccountType.User }, + AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], null); + + Assert.Equal("UserA", account.Id); + Assert.Equal(2, account.GetSubscriptions(client.Profile).Count); + var subrdfe1 = account.GetSubscriptions(client.Profile).FirstOrDefault(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId)); + var userA = client.GetAccount("UserA"); + var userB = client.GetAccount("UserB"); + var subGuest = userB.GetSubscriptions(client.Profile).FirstOrDefault(s => s.Id == new Guid(guestRdfeSubscription.SubscriptionId)); + Assert.NotNull(userA); + Assert.NotNull(userB); + Assert.Contains(rdfeSubscription1.SubscriptionId, userA.GetPropertyAsArray(AzureAccount.Property.Subscriptions), StringComparer.OrdinalIgnoreCase); + Assert.Contains(guestRdfeSubscription.SubscriptionId, userB.GetPropertyAsArray(AzureAccount.Property.Subscriptions), StringComparer.OrdinalIgnoreCase); + Assert.NotNull(subrdfe1); + Assert.NotNull(subGuest); + Assert.Equal("UserA", subrdfe1.Account); + Assert.Equal("UserB", subGuest.Account); + } + /// + /// Test that when accountId is added more than once with different capitalization, only a single accountId is added + /// and that accounts can be retrieved case-insensitively + /// + [Fact] + public void AddAzureAccountIsCaseInsensitive() + { + SetMocks(new[] { rdfeSubscription1, guestRdfeSubscription }.ToList(), + new List(), + new[] { commonTenant, guestTenant }.ToList(), + (userAccount, environment, tenant) => + { + var token = new MockAccessToken + { + UserId = tenant == commonTenant.TenantId ? userAccount.Id : "USERA", + AccessToken = "def", + LoginType = LoginType.OrgId + }; + userAccount.Id = token.UserId; + return token; + }); + MemoryDataStore dataStore = new MemoryDataStore(); + dataStore.VirtualStore[oldProfileDataPath] = oldProfileData; + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + var account = client.AddAccountAndLoadSubscriptions(new AzureAccount { Id = "UserA", Type = AzureAccount.AccountType.User }, + AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], null); + + var userA = client.GetAccount("UserA"); + var secondUserA = client.GetAccount("USERA"); + Assert.NotNull(userA); + Assert.NotNull(secondUserA); + Assert.Equal(userA.Id, secondUserA.Id); + } + + [Fact] + public void GetAzureAccountReturnsAccountWithSubscriptions() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1; + client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2; + client.Profile.Subscriptions[azureSubscription3withoutUser.Id] = azureSubscription3withoutUser; + client.Profile.Accounts[azureAccount.Id] = azureAccount; + client.Profile.Environments[azureEnvironment.Name] = azureEnvironment; + + var account = client.ListAccounts("test").ToList(); + + Assert.Equal(1, account.Count); + Assert.Equal("test", account[0].Id); + Assert.Equal(2, account[0].GetSubscriptions(client.Profile).Count); + Assert.True(account[0].GetSubscriptions(client.Profile).Any(s => s.Id == azureSubscription1.Id)); + Assert.True(account[0].GetSubscriptions(client.Profile).Any(s => s.Id == azureSubscription2.Id)); + } + + [Fact] + public void GetAzureAccountWithoutEnvironmentReturnsAccount() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1; + client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2; + client.Profile.Subscriptions[azureSubscription3withoutUser.Id] = azureSubscription3withoutUser; + client.Profile.Accounts[azureAccount.Id] = azureAccount; + client.Profile.Environments[azureEnvironment.Name] = azureEnvironment; + + var account = client.ListAccounts("test").ToList(); + + Assert.Equal(1, account.Count); + Assert.Equal("test", account[0].Id); + Assert.Equal(2, account[0].GetSubscriptions(client.Profile).Count); + Assert.True(account[0].GetSubscriptions(client.Profile).Any(s => s.Id == azureSubscription1.Id)); + Assert.True(account[0].GetSubscriptions(client.Profile).Any(s => s.Id == azureSubscription2.Id)); + } + + [Fact] + public void GetAzureAccountReturnsEmptyEnumerationForNonExistingUser() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1; + client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2; + client.Profile.Subscriptions[azureSubscription3withoutUser.Id] = azureSubscription3withoutUser; + client.Profile.Accounts[azureAccount.Id] = azureAccount; + client.Profile.Environments[azureEnvironment.Name] = azureEnvironment; + + var account = client.ListAccounts("test2").ToList(); + + Assert.Equal(0, account.Count); + } + + [Fact] + public void GetAzureAccountReturnsAllAccountsWithNullUser() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1; + client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2; + client.Profile.Accounts[azureAccount.Id] = azureAccount; + azureSubscription3withoutUser.Account = "test2"; + client.Profile.Accounts["test2"] = new AzureAccount + { + Id = "test2", + Type = AzureAccount.AccountType.User, + Properties = new Dictionary + { + {AzureAccount.Property.Subscriptions, azureSubscription3withoutUser.Id.ToString()} + } + }; + client.Profile.Subscriptions[azureSubscription3withoutUser.Id] = azureSubscription3withoutUser; + client.Profile.Environments[azureEnvironment.Name] = azureEnvironment; + + var account = client.ListAccounts(null).ToList(); + + Assert.Equal(2, account.Count); + } + + [Fact] + public void RemoveAzureAccountRemovesSubscriptions() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1; + client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2; + client.Profile.Accounts[azureAccount.Id] = azureAccount; + azureSubscription3withoutUser.Account = "test2"; + client.Profile.Accounts["test2"] = new AzureAccount + { + Id = "test2", + Type = AzureAccount.AccountType.User, + Properties = new Dictionary + { + {AzureAccount.Property.Subscriptions, azureSubscription3withoutUser.Id.ToString()} + } + }; + client.Profile.Subscriptions[azureSubscription3withoutUser.Id] = azureSubscription3withoutUser; + client.Profile.Environments[azureEnvironment.Name] = azureEnvironment; + List log = new List(); + client.WarningLog = log.Add; + + Assert.Equal(3, client.Profile.Subscriptions.Count); + + client.RemoveAccount("test2"); + + Assert.Equal(2, client.Profile.Subscriptions.Count); + Assert.Equal(0, log.Count); + } + + [Fact] + public void RemoveAzureAccountRemovesDefaultSubscriptionAndWritesWarning() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + ProfileClient client = new ProfileClient(currentProfile); + + client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1; + client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2; + client.Profile.Accounts[azureAccount.Id] = azureAccount; + azureSubscription3withoutUser.Account = "test2"; + client.Profile.Accounts["test2"] = new AzureAccount + { + Id = "test2", + Type = AzureAccount.AccountType.User, + Properties = new Dictionary + { + {AzureAccount.Property.Subscriptions, azureSubscription3withoutUser.Id.ToString()} + } + }; + client.Profile.Subscriptions[azureSubscription3withoutUser.Id] = azureSubscription3withoutUser; + client.Profile.Environments[azureEnvironment.Name] = azureEnvironment; + List log = new List(); + client.WarningLog = log.Add; + + Assert.Equal(3, client.Profile.Subscriptions.Count); + + var account = client.RemoveAccount("test"); + + Assert.Equal(1, client.Profile.Subscriptions.Count); + Assert.Equal("test", account.Id); + Assert.Equal(2, account.GetPropertyAsArray(AzureAccount.Property.Subscriptions).Length); + Assert.Equal(1, log.Count); + Assert.Equal( + "The default subscription is being removed. Use Select-AzureSubscription -Default to select a new default subscription.", + log[0]); + } + + [Fact] + public void RemoveAzureAccountRemovesDefaultAccountFromSubscription() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1; + client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2; + client.Profile.Accounts[azureAccount.Id] = azureAccount; + azureSubscription3withoutUser.Account = "test2"; + client.Profile.Accounts["test2"] = new AzureAccount + { + Id = "test2", + Type = AzureAccount.AccountType.User, + Properties = new Dictionary + { + {AzureAccount.Property.Subscriptions, azureSubscription1.Id.ToString()} + } + }; + client.Profile.Subscriptions[azureSubscription1.Id].Account = azureAccount.Id; + client.Profile.Environments[azureEnvironment.Name] = azureEnvironment; + + var account = client.RemoveAccount(azureAccount.Id); + + Assert.Equal("test2", client.Profile.Subscriptions[azureSubscription1.Id].Account); + } + + [Fact] + public void RemoveAzureAccountRemovesInMemoryAccount() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + ProfileClient client = new ProfileClient(currentProfile); + client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1; + client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2; + client.Profile.Accounts[azureAccount.Id] = azureAccount; + azureSubscription3withoutUser.Account = "test2"; + client.Profile.Accounts["test2"] = new AzureAccount + { + Id = "test2", + Type = AzureAccount.AccountType.User, + Properties = new Dictionary + { + {AzureAccount.Property.Subscriptions, azureSubscription1.Id.ToString()} + } + }; + client.Profile.Subscriptions[azureSubscription1.Id].Account = azureAccount.Id; + client.Profile.Environments[azureEnvironment.Name] = azureEnvironment; + currentProfile.DefaultSubscription = azureSubscription1; + + client.RemoveAccount(azureAccount.Id); + + Assert.Equal("test2", currentProfile.DefaultContext.Account.Id); + Assert.Equal("test2", currentProfile.DefaultContext.Subscription.Account); + Assert.Equal(azureSubscription1.Id, currentProfile.DefaultContext.Subscription.Id); + + client.RemoveAccount("test2"); + + Assert.Null(currentProfile.DefaultContext.Account); + Assert.Null(currentProfile.DefaultContext.Subscription); + Assert.Null(currentProfile.DefaultContext.Environment); + } + + [Fact] + public void AddAzureEnvironmentAddsEnvironment() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + Assert.Equal(2, client.Profile.Environments.Count); + + Assert.Throws(() => client.AddOrSetEnvironment(null)); + var env = client.AddOrSetEnvironment(azureEnvironment); + + Assert.Equal(3, client.Profile.Environments.Count); + Assert.Equal(env, azureEnvironment); + } + + [Fact] + public void GetAzureEnvironmentsListsEnvironments() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + var env1 = client.ListEnvironments(null); + + Assert.Equal(2, env1.Count); + + var env2 = client.ListEnvironments("bad"); + + Assert.Equal(0, env2.Count); + + var env3 = client.ListEnvironments(EnvironmentName.AzureCloud); + + Assert.Equal(1, env3.Count); + } + + [Fact] + public void RemoveAzureEnvironmentRemovesEnvironmentSubscriptionsAndAccounts() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + client.Profile.Accounts[azureAccount.Id] = azureAccount; + client.Profile.Environments[azureEnvironment.Name] = azureEnvironment; + client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1; + client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2; + + Assert.Equal(2, client.Profile.Subscriptions.Values.Count(s => s.Environment == "Test")); + Assert.Equal(3, client.Profile.Environments.Count); + Assert.Equal(1, client.Profile.Accounts.Count); + + Assert.Throws(() => client.RemoveEnvironment(null)); + Assert.Throws(() => client.RemoveEnvironment("bad")); + + var env = client.RemoveEnvironment(azureEnvironment.Name); + + Assert.Equal(azureEnvironment.Name, env.Name); + Assert.Equal(0, client.Profile.Subscriptions.Values.Count(s => s.Environment == "Test")); + Assert.Equal(2, client.Profile.Environments.Count); + Assert.Equal(0, client.Profile.Accounts.Count); + } + + [Fact] + public void RemoveAzureEnvironmentDoesNotRemoveEnvironmentSubscriptionsAndAccountsForAzureCloudOrChinaCloud() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + client.Profile.Accounts[azureAccount.Id] = azureAccount; + azureSubscription1.Environment = EnvironmentName.AzureCloud; + azureSubscription2.Environment = EnvironmentName.AzureChinaCloud; + client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1; + client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2; + + Assert.Equal(1, client.Profile.Subscriptions.Values.Count(s => s.Environment == EnvironmentName.AzureCloud)); + Assert.Equal(1, client.Profile.Subscriptions.Values.Count(s => s.Environment == EnvironmentName.AzureChinaCloud)); + Assert.Equal(2, client.Profile.Environments.Count); + Assert.Equal(1, client.Profile.Accounts.Count); + + Assert.Throws(() => client.RemoveEnvironment(EnvironmentName.AzureCloud)); + Assert.Throws(() => client.RemoveEnvironment(EnvironmentName.AzureChinaCloud)); + + Assert.Equal(1, client.Profile.Subscriptions.Values.Count(s => s.Environment == EnvironmentName.AzureCloud)); + Assert.Equal(1, client.Profile.Subscriptions.Values.Count(s => s.Environment == EnvironmentName.AzureChinaCloud)); + Assert.Equal(2, client.Profile.Environments.Count); + Assert.Equal(1, client.Profile.Accounts.Count); + } + + [Fact] + public void SetAzureEnvironmentUpdatesEnvironment() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + Assert.Equal(2, client.Profile.Environments.Count); + + Assert.Throws(() => client.AddOrSetEnvironment(null)); + + var env2 = client.AddOrSetEnvironment(azureEnvironment); + Assert.Equal(env2.Name, azureEnvironment.Name); + Assert.NotNull(env2.Endpoints[AzureEnvironment.Endpoint.ServiceManagement]); + AzureEnvironment newEnv = new AzureEnvironment + { + Name = azureEnvironment.Name + }; + newEnv.Endpoints[AzureEnvironment.Endpoint.Graph] = "foo"; + env2 = client.AddOrSetEnvironment(newEnv); + Assert.Equal("foo", env2.Endpoints[AzureEnvironment.Endpoint.Graph]); + Assert.NotNull(env2.Endpoints[AzureEnvironment.Endpoint.ServiceManagement]); + } + + [Fact] + public void GetAzureEnvironmentReturnsCorrectValue() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + ProfileClient client = new ProfileClient(currentProfile); + client.AddOrSetEnvironment(azureEnvironment); + + var defaultEnv = client.GetEnvironmentOrDefault(null); + + Assert.Equal(EnvironmentName.AzureCloud, defaultEnv.Name); + + var newEnv = client.GetEnvironmentOrDefault(azureEnvironment.Name); + + Assert.Equal(azureEnvironment.Name, newEnv.Name); + + Assert.Throws(() => client.GetEnvironmentOrDefault("bad")); + } + + [Fact] + public void GetCurrentEnvironmentReturnsCorrectValue() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + ProfileClient client = new ProfileClient(currentProfile); + + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetAccount(azureAccount); + client.AddOrSetSubscription(azureSubscription1); + + currentProfile.DefaultSubscription = azureSubscription1; + + var newEnv = client.GetEnvironmentOrDefault(azureEnvironment.Name); + + Assert.Equal(azureEnvironment.Name, newEnv.Name); + } + + [Fact] + public void AddOrSetAzureSubscriptionChecksAndUpdates() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + client.AddOrSetAccount(azureAccount); + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetSubscription(azureSubscription1); + + Assert.Equal(1, client.Profile.Subscriptions.Count); + + var subscription = client.AddOrSetSubscription(azureSubscription1); + + Assert.Equal(1, client.Profile.Subscriptions.Count); + Assert.Equal(1, client.Profile.Accounts.Count); + Assert.Equal(subscription, azureSubscription1); + Assert.Throws(() => client.AddOrSetSubscription(null)); + Assert.Throws(() => client.AddOrSetSubscription( + new AzureSubscription { Id = new Guid(), Environment = null, Name = "foo" })); + } + + [Fact] + public void AddOrSetAzureSubscriptionUpdatesInMemory() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + ProfileClient client = new ProfileClient(currentProfile); + + client.AddOrSetAccount(azureAccount); + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetSubscription(azureSubscription1); + currentProfile.DefaultSubscription = azureSubscription1; + azureSubscription1.Properties[AzureSubscription.Property.StorageAccount] = "testAccount"; + Assert.Equal(azureSubscription1.Id, currentProfile.DefaultContext.Subscription.Id); + Assert.Equal(azureSubscription1.Properties[AzureSubscription.Property.StorageAccount], + currentProfile.DefaultContext.Subscription.Properties[AzureSubscription.Property.StorageAccount]); + + var newSubscription = new AzureSubscription + { + Id = azureSubscription1.Id, + Environment = azureSubscription1.Environment, + Account = azureSubscription1.Account, + Name = azureSubscription1.Name + }; + newSubscription.Properties[AzureSubscription.Property.StorageAccount] = "testAccount1"; + + client.AddOrSetSubscription(newSubscription); + var newSubscriptionFromProfile = client.Profile.Subscriptions[newSubscription.Id]; + + Assert.Equal(newSubscription.Id, currentProfile.DefaultContext.Subscription.Id); + Assert.Equal(newSubscription.Id, newSubscriptionFromProfile.Id); + Assert.Equal(newSubscription.Properties[AzureSubscription.Property.StorageAccount], + currentProfile.DefaultContext.Subscription.Properties[AzureSubscription.Property.StorageAccount]); + Assert.Equal(newSubscription.Properties[AzureSubscription.Property.StorageAccount], + newSubscriptionFromProfile.Properties[AzureSubscription.Property.StorageAccount]); + } + + [Fact] + public void RemoveAzureSubscriptionChecksAndRemoves() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + client.Profile.Accounts[azureAccount.Id] = azureAccount; + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetSubscription(azureSubscription1); + client.SetSubscriptionAsDefault(azureSubscription1.Name, azureSubscription1.Account); + + Assert.Equal(1, client.Profile.Subscriptions.Count); + + List log = new List(); + client.WarningLog = log.Add; + + var subscription = client.RemoveSubscription(azureSubscription1.Name); + + Assert.Equal(0, client.Profile.Subscriptions.Count); + Assert.Equal(azureSubscription1.Name, subscription.Name); + Assert.Equal(1, log.Count); + Assert.Equal( + "The default subscription is being removed. Use Select-AzureSubscription -Default to select a new default subscription.", + log[0]); + Assert.Throws(() => client.RemoveSubscription("bad")); + Assert.Throws(() => client.RemoveSubscription(null)); + } + + [Fact] + public void RefreshSubscriptionsUpdatesAccounts() + { + SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList()); + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.AddOrSetEnvironment(azureEnvironment); + client.Profile.Accounts[azureAccount.Id] = azureAccount; + client.AddOrSetSubscription(azureSubscription1); + + var subscriptions = client.RefreshSubscriptions(azureEnvironment); + + Assert.True(client.Profile.Accounts[azureAccount.Id].HasSubscription(new Guid(rdfeSubscription1.SubscriptionId))); + Assert.True(client.Profile.Accounts[azureAccount.Id].HasSubscription(new Guid(rdfeSubscription2.SubscriptionId))); + Assert.False(client.Profile.Accounts[azureAccount.Id].HasSubscription(new Guid(csmSubscription1.SubscriptionId))); + Assert.True(client.Profile.Accounts[azureAccount.Id].HasSubscription(new Guid(csmSubscription1withDuplicateId.SubscriptionId))); + } + + [Fact] + public void RefreshSubscriptionsMergesFromServer() + { + SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList()); + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.AddOrSetEnvironment(azureEnvironment); + client.Profile.Accounts[azureAccount.Id] = azureAccount; + client.AddOrSetSubscription(azureSubscription1); + + var subscriptions = client.RefreshSubscriptions(azureEnvironment); + + Assert.Equal(3, subscriptions.Count); + Assert.Equal(3, subscriptions.Count(s => s.Account == "test")); + Assert.Equal(1, subscriptions.Count(s => s.Id == azureSubscription1.Id)); + Assert.Equal(1, subscriptions.Count(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId))); + Assert.Equal(1, subscriptions.Count(s => s.Id == new Guid(rdfeSubscription2.SubscriptionId))); + Assert.Equal(0, subscriptions.Count(s => s.Id == new Guid(csmSubscription1.SubscriptionId))); + } + + [Fact] + public void RefreshSubscriptionsWorksWithMooncake() + { + SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList()); + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + client.Profile.Accounts[azureAccount.Id] = azureAccount; + + var subscriptions = client.RefreshSubscriptions(client.Profile.Environments[EnvironmentName.AzureChinaCloud]); + + Assert.Equal(2, subscriptions.Count); + Assert.Equal(2, subscriptions.Count(s => s.Account == "test")); + Assert.Equal(1, subscriptions.Count(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId))); + Assert.Equal(1, subscriptions.Count(s => s.Id == new Guid(rdfeSubscription2.SubscriptionId))); + } + + [Fact] + public void RefreshSubscriptionsListsAllSubscriptions() + { + SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList()); + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.AddOrSetAccount(azureAccount); + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetSubscription(azureSubscription1); + + var subscriptions = client.RefreshSubscriptions(azureEnvironment); + + Assert.Equal(3, subscriptions.Count); + Assert.Equal(1, subscriptions.Count(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId))); + Assert.Equal(1, subscriptions.Count(s => s.Id == new Guid(rdfeSubscription2.SubscriptionId))); + Assert.Equal(0, subscriptions.Count(s => s.Id == new Guid(csmSubscription1.SubscriptionId))); + Assert.True(subscriptions.All(s => s.Environment == "Test")); + Assert.True(subscriptions.All(s => s.Account == "test")); + } + + [Fact] + public void GetAzureSubscriptionByNameChecksAndReturnsOnlyLocal() + { + SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList()); + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.AddOrSetAccount(azureAccount); + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetSubscription(azureSubscription1); + client.AddOrSetSubscription(azureSubscription2); + + var subscriptions = client.GetSubscription(azureSubscription1.Name); + + Assert.Equal(azureSubscription1.Id, subscriptions.Id); + Assert.Throws(() => client.GetSubscription(new Guid())); + } + + [Fact] + public void GetAzureSubscriptionByIdChecksAndReturnsOnlyLocal() + { + SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList()); + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.AddOrSetAccount(azureAccount); + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetSubscription(azureSubscription1); + client.AddOrSetSubscription(azureSubscription2); + + var subscriptions = client.GetSubscription(azureSubscription1.Id); + + Assert.Equal(azureSubscription1.Id, subscriptions.Id); + Assert.Throws(() => client.GetSubscription(new Guid())); + } + + [Fact] + public void SetAzureSubscriptionAsDefaultSetsDefaultAndCurrent() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + ProfileClient client = new ProfileClient(currentProfile); + client.Profile.Accounts[azureAccount.Id] = azureAccount; + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetSubscription(azureSubscription2); + + Assert.Null(client.Profile.DefaultSubscription); + + client.SetSubscriptionAsDefault(azureSubscription2.Name, azureSubscription2.Account); + + Assert.Equal(azureSubscription2.Id, client.Profile.DefaultSubscription.Id); + Assert.Equal(azureSubscription2.Id, currentProfile.DefaultContext.Subscription.Id); + Assert.Equal(azureSubscription2.Account, currentProfile.DefaultContext.Account.Id); + Assert.Equal(azureSubscription2.Environment, currentProfile.DefaultContext.Environment.Name); + var notFoundEx = Assert.Throws(() => client.SetSubscriptionAsDefault("bad", null)); + var invalidEx = Assert.Throws(() => client.SetSubscriptionAsDefault(null, null)); + Assert.Contains("doesn't exist", notFoundEx.Message); + Assert.Contains("non-null", invalidEx.Message); + } + + [Fact] + public void ClearDefaultAzureSubscriptionClearsDefault() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.Profile.Accounts[azureAccount.Id] = azureAccount; + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetSubscription(azureSubscription2); + + Assert.Null(client.Profile.DefaultSubscription); + client.SetSubscriptionAsDefault(azureSubscription2.Name, azureSubscription2.Account); + Assert.Equal(azureSubscription2.Id, client.Profile.DefaultSubscription.Id); + + client.ClearDefaultSubscription(); + + Assert.Null(client.Profile.DefaultSubscription); + Assert.Null(client.Profile.DefaultContext.Account); + Assert.Null(client.Profile.DefaultContext.Environment); + Assert.Null(client.Profile.DefaultContext.Subscription); + } + + [Fact] + public void ImportPublishSettingsLoadsAndReturnsSubscriptions() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", + Microsoft.WindowsAzure.Commands.Common.Test.Properties.Resources.ValidProfile); + + client.AddOrSetEnvironment(azureEnvironment); + var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", azureEnvironment.Name); + var account = client.Profile.Accounts.Values.First(); + + Assert.True(subscriptions.All(s => s.Account == account.Id)); + Assert.Equal(6, subscriptions.Count); + Assert.Equal(6, client.Profile.Subscriptions.Count); + } + + [Fact] + public void ImportPublishSettingsDefaultsToAzureCloudEnvironmentWithManagementUrl() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.AddOrSetAccount(azureAccount); + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetSubscription(azureSubscription1); + client.SetSubscriptionAsDefault(azureSubscription1.Name, azureAccount.Id); + client.Profile.Save(); + + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + client = new ProfileClient(currentProfile); + + dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", + Microsoft.WindowsAzure.Commands.Common.Test.Properties.Resources.ValidProfile); + + client.AddOrSetEnvironment(azureEnvironment); + var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", null); + + Assert.True(subscriptions.All(s => s.Environment == EnvironmentName.AzureCloud)); + Assert.Equal(6, subscriptions.Count); + Assert.Equal(7, client.Profile.Subscriptions.Count); + } + + [Fact] + public void ImportPublishSettingsUsesProperEnvironmentWithManagementUrl() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.AddOrSetAccount(azureAccount); + azureEnvironment.Endpoints[AzureEnvironment.Endpoint.ServiceManagement] = "https://newmanagement.core.windows.net/"; + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetSubscription(azureSubscription1); + client.SetSubscriptionAsDefault(azureSubscription1.Name, azureAccount.Id); + client.Profile.Save(); + + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + client = new ProfileClient(currentProfile); + + dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", + Microsoft.WindowsAzure.Commands.Common.Test.Properties.Resources.ValidProfile3); + + client.AddOrSetEnvironment(azureEnvironment); + var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", null); + + Assert.True(subscriptions.All(s => s.Environment == azureEnvironment.Name)); + Assert.Equal(6, subscriptions.Count); + Assert.Equal(7, client.Profile.Subscriptions.Count); + } + + [Fact] + public void ImportPublishSettingsUsesProperEnvironmentWithChinaManagementUrl() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", + Microsoft.WindowsAzure.Commands.Common.Test.Properties.Resources.ValidProfileChina); + + client.AddOrSetEnvironment(azureEnvironment); + var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", null); + + Assert.True(subscriptions.All(s => s.Environment == EnvironmentName.AzureChinaCloud)); + Assert.Equal(6, subscriptions.Count); + Assert.Equal(6, client.Profile.Subscriptions.Count); + } + + [Fact] + public void ImportPublishSettingsUsesProperEnvironmentWithChinaManagementUrlOld() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + + dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", + Microsoft.WindowsAzure.Commands.Common.Test.Properties.Resources.ValidProfileChinaOld); + + client.AddOrSetEnvironment(azureEnvironment); + var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", null); + + Assert.True(subscriptions.All(s => s.Environment == EnvironmentName.AzureChinaCloud)); + Assert.Equal(1, subscriptions.Count); + Assert.Equal(1, client.Profile.Subscriptions.Count); + } + + [Fact] + public void ImportPublishSettingsDefaultsToAzureCloudWithIncorrectManagementUrl() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.AddOrSetAccount(azureAccount); + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetSubscription(azureSubscription1); + client.SetSubscriptionAsDefault(azureSubscription1.Name, azureAccount.Id); + client.Profile.Save(); + + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + client = new ProfileClient(currentProfile); + + dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", + Microsoft.WindowsAzure.Commands.Common.Test.Properties.Resources.ValidProfile3); + + client.AddOrSetEnvironment(azureEnvironment); + var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", null); + + Assert.True(subscriptions.All(s => s.Environment == EnvironmentName.AzureCloud)); + Assert.Equal(6, subscriptions.Count); + Assert.Equal(7, client.Profile.Subscriptions.Count); + } + + [Fact] + public void ImportPublishSettingsUsesPassedInEnvironment() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + client.AddOrSetAccount(azureAccount); + client.AddOrSetEnvironment(azureEnvironment); + client.AddOrSetSubscription(azureSubscription1); + client.SetSubscriptionAsDefault(azureSubscription1.Name, azureAccount.Id); + client.Profile.Save(); + + client = new ProfileClient(currentProfile); + + dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", + Microsoft.WindowsAzure.Commands.Common.Test.Properties.Resources.ValidProfile3); + + client.AddOrSetEnvironment(azureEnvironment); + var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", azureEnvironment.Name); + + Assert.True(subscriptions.All(s => s.Environment == azureEnvironment.Name)); + Assert.Equal(6, subscriptions.Count); + Assert.Equal(7, client.Profile.Subscriptions.Count); + } + + [Fact] + public void ImportPublishSettingsAddsSecondCertificate() + { + MemoryDataStore dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + ProfileClient client = new ProfileClient(currentProfile); + var newSubscription = new AzureSubscription + { + Id = new Guid("f62b1e05-af8f-4203-8f97-421089adc053"), + Name = "Microsoft Azure Sandbox 9-220", + Environment = EnvironmentName.AzureCloud, + Account = azureAccount.Id + }; + azureAccount.SetProperty(AzureAccount.Property.Subscriptions, newSubscription.Id.ToString()); + client.AddOrSetAccount(azureAccount); + client.AddOrSetSubscription(newSubscription); + client.Profile.Save(); + + currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + client = new ProfileClient(currentProfile); + + dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", + Microsoft.WindowsAzure.Commands.Common.Test.Properties.Resources.ValidProfile); + + client.AddOrSetEnvironment(azureEnvironment); + var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", azureEnvironment.Name); + + Assert.Equal(2, client.Profile.Accounts.Count()); + var certAccount = client.Profile.Accounts.Values.First(a => a.Type == AzureAccount.AccountType.Certificate); + var userAccount = client.Profile.Accounts.Values.First(a => a.Type == AzureAccount.AccountType.User); + + Assert.True(subscriptions.All(s => s.Account == certAccount.Id)); + Assert.Equal(azureAccount.Id, client.Profile.Subscriptions.Values.First(s => s.Id == newSubscription.Id).Account); + + Assert.True(userAccount.GetPropertyAsArray(AzureAccount.Property.Subscriptions).Contains(newSubscription.Id.ToString())); + Assert.True(certAccount.GetPropertyAsArray(AzureAccount.Property.Subscriptions).Contains(newSubscription.Id.ToString())); + + Assert.Equal(6, subscriptions.Count); + Assert.Equal(6, client.Profile.Subscriptions.Count); + } + + private void SetMocks(List rdfeSubscriptions, + List csmSubscriptions, + List tenants = null, + Func tokenProvider = null) + { + ClientMocks clientMocks = new ClientMocks(new Guid(defaultSubscription)); + + clientMocks.LoadRdfeSubscriptions(rdfeSubscriptions); + clientMocks.LoadCsmSubscriptions(csmSubscriptions); + clientMocks.LoadTenants(tenants); + + AzureSession.ClientFactory = new MockClientFactory(new object[] { clientMocks.RdfeSubscriptionClientMock.Object, + clientMocks.CsmSubscriptionClientMock.Object }) + { + MoqClients = true + }; + + var mockFactory = new MockTokenAuthenticationFactory(); + if (tokenProvider != null) + { + mockFactory.TokenProvider = tokenProvider; + } + + AzureSession.AuthenticationFactory = mockFactory; + } + + private void SetMockData() + { + commonTenant = new TenantIdDescription + { + Id = "Common", + TenantId = "Common" + }; + guestTenant = new TenantIdDescription + { + Id = "Guest", + TenantId = "Guest" + }; + rdfeSubscription1 = new RDFESubscription + { + SubscriptionId = "16E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E", + SubscriptionName = "RdfeSub1", + SubscriptionStatus = Microsoft.WindowsAzure.Subscriptions.Models.SubscriptionStatus.Active, + ActiveDirectoryTenantId = "Common" + }; + rdfeSubscription2 = new RDFESubscription + { + SubscriptionId = "26E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E", + SubscriptionName = "RdfeSub2", + SubscriptionStatus = Microsoft.WindowsAzure.Subscriptions.Models.SubscriptionStatus.Active, + ActiveDirectoryTenantId = "Common" + }; + guestRdfeSubscription = new RDFESubscription + { + SubscriptionId = "26E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1C", + SubscriptionName = "RdfeSub2", + SubscriptionStatus = Microsoft.WindowsAzure.Subscriptions.Models.SubscriptionStatus.Active, + ActiveDirectoryTenantId = "Guest" + }; + csmSubscription1 = new CSMSubscription + { + Id = "Subscriptions/36E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E", + DisplayName = "CsmSub1", + State = "Active", + SubscriptionId = "36E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E" + }; + csmSubscription1withDuplicateId = new CSMSubscription + { + Id = "Subscriptions/16E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E", + DisplayName = "RdfeSub1", + State = "Active", + SubscriptionId = "16E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E" + }; + csmSubscription2 = new CSMSubscription + { + Id = "Subscriptions/46E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E", + DisplayName = "CsmSub2", + State = "Active", + SubscriptionId = "46E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E" + }; + guestCsmSubscription = new CSMSubscription + { + Id = "Subscriptions/76E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1D", + DisplayName = "CsmGuestSub", + State = "Active", + SubscriptionId = "76E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1D" + }; + azureSubscription1 = new AzureSubscription + { + Id = new Guid("56E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E"), + Name = "LocalSub1", + Environment = "Test", + Account = "test", + Properties = new Dictionary + { + { AzureSubscription.Property.Default, "True" } + } + }; + azureSubscription2 = new AzureSubscription + { + Id = new Guid("66E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E"), + Name = "LocalSub2", + Environment = "Test", + Account = "test" + }; + azureSubscription3withoutUser = new AzureSubscription + { + Id = new Guid("76E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E"), + Name = "LocalSub3", + Environment = "Test", + }; + azureEnvironment = new AzureEnvironment + { + Name = "Test", + Endpoints = new Dictionary + { + { AzureEnvironment.Endpoint.ServiceManagement, "https://umapi.rdfetest.dnsdemo4.com:8443/" }, + { AzureEnvironment.Endpoint.ManagementPortalUrl, "https://windows.azure-test.net" }, + { AzureEnvironment.Endpoint.AdTenant, "https://login.windows-ppe.net/" }, + { AzureEnvironment.Endpoint.ActiveDirectory, "https://login.windows-ppe.net/" }, + { AzureEnvironment.Endpoint.Gallery, "https://current.gallery.azure-test.net" }, + { AzureEnvironment.Endpoint.ResourceManager, "https://api-current.resources.windows-int.net/" }, + } + }; + azureAccount = new AzureAccount + { + Id = "test", + Type = AzureAccount.AccountType.User, + Properties = new Dictionary + { + { AzureAccount.Property.Subscriptions, azureSubscription1.Id + "," + azureSubscription2.Id } + } + }; + newProfileDataPath = Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile); + oldProfileDataPath = Path.Combine(AzureSession.ProfileDirectory, AzureSession.OldProfileFile); + oldProfileDataPathError = Path.Combine(AzureSession.ProfileDirectory, AzureSession.OldProfileFileBackup); + oldProfileData = @" + + AzureCloud + + + https://management.core.windows.net/ + https://login.windows-ppe.net/ + Common + https://current.gallery.azure-test.net + http://go.microsoft.com/fwlink/?LinkId=254433 + Current + d:\Code\azure.publishsettings + https://api-current.resources.windows-int.net/ + https://umapi.rdfetest.dnsdemo4.com:8443/ + .database.windows.net + + trafficmanager.net + + + https://management.core.windows.net/ + https://login.windows-ppe.net/ + Common + https://df.gallery.azure-test.net + https://windows.azure-test.net + Dogfood + https://auxnext.windows.azure-test.net/publishsettings/index + https://api-dogfood.resources.windows-int.net + https://management-preview.core.windows-int.net/ + .database.windows.net + + trafficmanager.net + + + + + + + + + + + true + + + https://management.core.windows.net/ + Test + + + .database.windows.net + 06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E + trafficmanager.net + + + + + 123 + test@mail.com + + + true + + + https://management-preview.core.windows-int.net/ + Test 2 + + + .database.windows.net + 06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F + trafficmanager.net + + + https://login.windows.net/ + https://management.core.windows.net/ + 72f988bf-86f1-41af-91ab-2d7cd011db47 + test@mail.com + + + false + + 3AF24D48B97730E5C4C9CCB12397B5E046F79E09 + https://management.core.windows.net/ + Test 3 + + + .database.windows.net + d1e52cbc-b073-42e2-a0a0-c2f547118a6f + trafficmanager.net + + + + + + + + + false + + 3AF24D48B97730E5C4C9CCB12397B5E046F79E09 + https://management.core.chinacloudapi.cn/ + Mooncake Test + + + .database.windows.net + c14d7dc5-ed4d-4346-a02f-9f1bcf78fb66 + trafficmanager.net + + + "; + + oldProfileDataBadSubscription = @" + + AzureCloud + + + + + + + + + + + true + + + https://management.core.windows.net/ + Test Nill ID + + + .database.windows.net + + trafficmanager.net + + + + + + test@mail.com + + + true + + + Bad Data + Test Bad Management Endpoint + + + .database.windows.net + 06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F + trafficmanager.net + + + + + + test@mail.com + + + true + + + + Test Null Management Endpoint + + + .database.windows.net + 06E3F6FD-A3AA-439A-8FC4-1F5C41D2ADFF + trafficmanager.net + + + https://login.windows.net/ + https://management.core.windows.net/ + 72f988bf-86f1-41af-91ab-2d7cd011db47 + test@mail.com + + + false + + 3AF24D48B97730E5C4C9CCB12397B5E046F79E99 + https://management.core.windows.net/ + Test Bad Cert + + + .database.windows.net + d1e52cbc-b073-42e2-a0a0-c2f547118a6f + trafficmanager.net + + + "; + + oldProfileDataCorruptedFile = @" + + AzureCloud + + + https://management.core.windows.net/ + https://login.windows-ppe.net/ + Common + https://current.gallery.azure-test.net + http://go.microsoft.com/fwlink/?LinkId=254433 + Current + d:\Code\azure.publishsettings + https://api-current.resources.windows-int.net/ + https://umapi.rdfetest.dnsdemo4.com:8443/ + .database.windows.net + + trafficmanager.net + + + + "; + } + } +} diff --git a/src/Common/Commands.Common.Test/Properties/AssemblyInfo.cs b/src/Common/Commands.Common.Test/Properties/AssemblyInfo.cs index 47808fece783..60082316ea0c 100644 --- a/src/Common/Commands.Common.Test/Properties/AssemblyInfo.cs +++ b/src/Common/Commands.Common.Test/Properties/AssemblyInfo.cs @@ -16,6 +16,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using Xunit; [assembly: AssemblyTitle("Microsoft Azure Powershell - Common Library")] [assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)] @@ -27,6 +28,7 @@ [assembly: Guid("080bc9b8-3c00-4d0e-bec2-38d2fd0d7061")] [assembly: AssemblyVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyVersion)] [assembly: AssemblyFileVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyFileVersion)] + #if SIGN [assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] #else diff --git a/src/Common/Commands.Common.Test/packages.config b/src/Common/Commands.Common.Test/packages.config index 705bcc0a0611..85021bc6a70e 100644 --- a/src/Common/Commands.Common.Test/packages.config +++ b/src/Common/Commands.Common.Test/packages.config @@ -2,10 +2,11 @@ - + + - + @@ -25,5 +26,7 @@ - - + + + + \ No newline at end of file diff --git a/src/Common/Commands.Common/AzurePowerShell.cs b/src/Common/Commands.Common/AzurePowerShell.cs index bedbdfe79baa..dd3e122f685f 100644 --- a/src/Common/Commands.Common/AzurePowerShell.cs +++ b/src/Common/Commands.Common/AzurePowerShell.cs @@ -12,10 +12,10 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Common.Authentication.Properties; using System; using System.IO; using System.Net.Http.Headers; +using Microsoft.Azure.Common.Authentication.Properties; namespace Microsoft.WindowsAzure.Commands.Common { @@ -27,9 +27,9 @@ public class AzurePowerShell public const string AssemblyCopyright = "Copyright © Microsoft"; - public const string AssemblyVersion = "0.9.7"; + public const string AssemblyVersion = "0.9.8"; - public const string AssemblyFileVersion = "0.9.7"; + public const string AssemblyFileVersion = "0.9.8"; public const string ProfileFile = "AzureProfile.json"; diff --git a/src/Common/Commands.Common/AzureSMCmdlet.cs b/src/Common/Commands.Common/AzureSMCmdlet.cs new file mode 100644 index 000000000000..f55c8e982246 --- /dev/null +++ b/src/Common/Commands.Common/AzureSMCmdlet.cs @@ -0,0 +1,174 @@ +// ---------------------------------------------------------------------------------- +// +// 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.Concurrent; +using System.Diagnostics; +using System.IO; +using System.Management.Automation; +using Microsoft.Azure.Common.Authentication; +using Microsoft.Azure.Common.Authentication.Models; +using Microsoft.IdentityModel.Clients.ActiveDirectory; +using Microsoft.WindowsAzure.Commands.Common; +using Microsoft.WindowsAzure.Commands.Common.Properties; + +namespace Microsoft.WindowsAzure.Commands.Utilities.Common +{ + public abstract class AzureSMCmdlet : AzurePSCmdlet + { + protected static AzureSMProfile _currentProfile = null; + + [Parameter(Mandatory = false, HelpMessage = "In-memory profile.")] + public AzureSMProfile Profile { get; set; } + + /// + /// Sets the current profile - the profile used when no Profile is explicitly passed in. Should be used only by + /// Profile cmdlets and tests that need to set up a particular profile + /// + public static AzureSMProfile CurrentProfile + { + private get + { + if (_currentProfile == null) + { + _currentProfile = InitializeDefaultProfile(); + SetTokenCacheForProfile(_currentProfile); + } + + return _currentProfile; + } + + set + { + SetTokenCacheForProfile(value); + _currentProfile = value; + } + } + + protected static TokenCache DefaultDiskTokenCache { get; set; } + + protected static TokenCache DefaultMemoryTokenCache { get; set; } + + protected override AzureContext DefaultContext { get { return CurrentProfile.DefaultContext; } } + + static AzureSMCmdlet() + { + if (!TestMockSupport.RunningMocked) + { + AzureSession.ClientFactory.AddAction(new RPRegistrationAction()); + } + + if (!TestMockSupport.RunningMocked) + { + InitializeTokenCaches(); + AzureSession.DataStore = new DiskDataStore(); + SetTokenCacheForProfile(CurrentProfile); + } + } + + /// + /// Create the default profile, based on the default profile path + /// + /// The default profile, serialized from the default location on disk + protected static AzureSMProfile InitializeDefaultProfile() + { + if (!string.IsNullOrEmpty(AzureSession.ProfileDirectory) && !string.IsNullOrEmpty(AzureSession.ProfileFile)) + { + try + { + GeneralUtilities.EnsureDefaultProfileDirectoryExists(); + return new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)); + } + catch + { + // swallow exceptions in creating the profile from disk + } + } + + return new AzureSMProfile(); + } + + protected static void InitializeTokenCaches() + { + DefaultMemoryTokenCache = TokenCache.DefaultShared; + if (!string.IsNullOrWhiteSpace(AzureSession.ProfileDirectory) && + !string.IsNullOrWhiteSpace(AzureSession.TokenCacheFile)) + { + GeneralUtilities.EnsureDefaultProfileDirectoryExists(); + DefaultDiskTokenCache = new ProtectedFileTokenCache(Path.Combine(AzureSession.ProfileDirectory, AzureSession.TokenCacheFile)); + } + else + { + DefaultDiskTokenCache = DefaultMemoryTokenCache; + } + } + + /// + /// Update the token cache when setting the profile + /// + /// + protected static void SetTokenCacheForProfile(AzureSMProfile profile) + { + var defaultProfilePath = Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile); + if (string.Equals(profile.ProfilePath, defaultProfilePath, StringComparison.OrdinalIgnoreCase)) + { + AzureSession.TokenCache = DefaultDiskTokenCache; + } + else + { + AzureSession.TokenCache = DefaultMemoryTokenCache; + } + } + + /// + /// Cmdlet begin process. Write to logs, setup Http Tracing and initialize profile + /// + protected override void BeginProcessing() + { + InitializeProfile(); + base.BeginProcessing(); + } + + /// + /// Ensure that there is a profile for the command + /// + protected virtual void InitializeProfile() + { + if (Profile == null) + { + Profile = AzureSMCmdlet.CurrentProfile; + } + + SetTokenCacheForProfile(Profile); + } + + public virtual void ExecuteCmdlet() + { + // Do nothing. + } + + protected override void ProcessRecord() + { + try + { + base.ProcessRecord(); + ExecuteCmdlet(); + } + catch (Exception ex) + { + WriteExceptionError(ex); + } + } + } +} diff --git a/src/Common/Commands.Common/ChannelHelper.cs b/src/Common/Commands.Common/ChannelHelper.cs index 57a41327e92b..9757b33d2f9e 100644 --- a/src/Common/Commands.Common/ChannelHelper.cs +++ b/src/Common/Commands.Common/ChannelHelper.cs @@ -12,8 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.ServiceManagement.Model; using System; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -29,6 +27,8 @@ using System.Text; using System.Threading; using System.Xml; +using Microsoft.WindowsAzure.Commands.Common; +using Microsoft.WindowsAzure.Commands.ServiceManagement.Model; namespace Microsoft.WindowsAzure.Commands.Utilities.Common { diff --git a/src/Common/Commands.Common/CloudBaseCmdlet.cs b/src/Common/Commands.Common/CloudBaseCmdlet.cs index 9d9463a3e207..b8a60902a482 100644 --- a/src/Common/Commands.Common/CloudBaseCmdlet.cs +++ b/src/Common/Commands.Common/CloudBaseCmdlet.cs @@ -12,10 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Common.Authentication; -using Microsoft.Azure.Common.Authentication.Models; -using Microsoft.WindowsAzure.Commands.Common.Properties; -using Microsoft.WindowsAzure.Commands.ServiceManagement.Model; using System; using System.Diagnostics; using System.Globalization; @@ -24,10 +20,14 @@ using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Security; +using Microsoft.Azure.Common.Authentication; +using Microsoft.Azure.Common.Authentication.Models; +using Microsoft.WindowsAzure.Commands.Common.Properties; +using Microsoft.WindowsAzure.Commands.ServiceManagement.Model; namespace Microsoft.WindowsAzure.Commands.Utilities.Common { - public abstract class CloudBaseCmdlet : AzurePSCmdlet + public abstract class CloudBaseCmdlet : AzureSMCmdlet where T : class { private Binding _serviceBinding; @@ -81,12 +81,12 @@ protected virtual void InitChannelCurrentSubscription(bool force) protected void DoInitChannelCurrentSubscription(bool force) { - if (Profile.Context.Subscription == null) + if (Profile.DefaultContext.Subscription == null) { throw new ArgumentException(Resources.InvalidDefaultSubscription); } - if (Profile.Context.Account == null) + if (Profile.DefaultContext.Account == null) { throw new ArgumentException(Resources.AccountNeedsToBeSpecified); } @@ -127,19 +127,19 @@ protected virtual T CreateChannel() return Channel; } - string certificateThumbprint = Profile.Context.Account.Id; + string certificateThumbprint = Profile.DefaultContext.Account.Id; Debug.Assert(Profile.Accounts[certificateThumbprint].Type == AzureAccount.AccountType.Certificate); return ChannelHelper.CreateServiceManagementChannel( ServiceBinding, - Profile.Context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement), + Profile.DefaultContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement), AzureSession.DataStore.GetCertificate(certificateThumbprint), new HttpRestMessageInspector(WriteDebug)); } protected void RetryCall(Action call) { - RetryCall(Profile.Context.Subscription.Id, call); + RetryCall(Profile.DefaultContext.Subscription.Id, call); } protected void RetryCall(Guid subsId, Action call) @@ -172,7 +172,7 @@ protected void RetryCall(Guid subsId, Action call) protected TResult RetryCall(Func call) { - return RetryCall(Profile.Context.Subscription.Id, call); + return RetryCall(Profile.DefaultContext.Subscription.Id, call); } protected TResult RetryCall(Guid subsId, Func call) diff --git a/src/Common/Commands.Common/CmdletExtensions.cs b/src/Common/Commands.Common/CmdletExtensions.cs index 9942a85f769a..c1cb970e42a3 100644 --- a/src/Common/Commands.Common/CmdletExtensions.cs +++ b/src/Common/Commands.Common/CmdletExtensions.cs @@ -123,13 +123,6 @@ public static void InvokeEndProcessing(this PSCmdlet cmdlt) MethodInfo dynMethod = (typeof(PSCmdlet)).GetMethod("EndProcessing", BindingFlags.NonPublic | BindingFlags.Instance); dynMethod.Invoke(cmdlt, null); } - public static void ExecuteWithProcessing(this AzurePSCmdlet cmdlt) - { - cmdlt.InvokeBeginProcessing(); - cmdlt.ExecuteCmdlet(); - cmdlt.InvokeEndProcessing(); - - } #endregion } diff --git a/src/Common/Commands.Common/Commands.Common.csproj b/src/Common/Commands.Common/Commands.Common.csproj index 2483d0c2e001..5cfe1949e29e 100644 --- a/src/Common/Commands.Common/Commands.Common.csproj +++ b/src/Common/Commands.Common/Commands.Common.csproj @@ -60,7 +60,7 @@ False - ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.3-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll False @@ -138,14 +138,21 @@ + + AzurePSCmdlet.cs + + True True Resources.resx + + + @@ -157,7 +164,7 @@ - + diff --git a/src/Common/Commands.Common/Common/ManagementConstants.cs b/src/Common/Commands.Common/Common/ManagementConstants.cs deleted file mode 100644 index 08da1656a6bc..000000000000 --- a/src/Common/Commands.Common/Common/ManagementConstants.cs +++ /dev/null @@ -1,112 +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. -// ---------------------------------------------------------------------------------- - -using System.Net.Http.Headers; -using Microsoft.WindowsAzure.Commands.Common; - -namespace Microsoft.WindowsAzure.Commands.Utilities.Common -{ - public static class ApiConstants - { - public const string AuthorizationHeaderName = "Authorization"; - - public const string BasicAuthorization = "Basic"; - - public const string UserAgentHeaderName = "User-Agent"; - - public const string UserAgentHeaderValue = "AzurePowershell/v" + AzurePowerShell.AssemblyVersion; - - public static ProductInfoHeaderValue UserAgentValue = new ProductInfoHeaderValue( - "AzurePowershell", - string.Format("v{0}", AzurePowerShell.AssemblyVersion)); - - public const string VSDebuggerCausalityDataHeaderName = "VSDebuggerCausalityData"; - - public const string OperationTrackingIdHeader = "x-ms-request-id"; - - public const string VersionHeaderContentLatest = "2013-08-01"; - - public const string VersionHeaderName = "x-ms-version"; - - } - - public enum DevEnv - { - Local, - Cloud - } - - public enum RoleType - { - WebRole, - WorkerRole - } - - public enum RuntimeType - { - IISNode, - Node, - PHP, - Cache, - Null - } - - public static class EnvironmentName - { - public const string AzureCloud = "AzureCloud"; - - public const string AzureChinaCloud = "AzureChinaCloud"; - } - - public static class AzureEnvironmentConstants - { - public const string AzureServiceEndpoint = "https://management.core.windows.net/"; - - public const string ChinaServiceEndpoint = "https://management.core.chinacloudapi.cn/"; - - public const string AzureResourceManagerEndpoint = "https://management.azure.com/"; - - public const string GalleryEndpoint = "https://gallery.azure.com/"; - - public const string AzurePublishSettingsFileUrl = "http://go.microsoft.com/fwlink/?LinkID=301775"; - - public const string ChinaPublishSettingsFileUrl = "http://go.microsoft.com/fwlink/?LinkID=301776"; - - public const string AzureManagementPortalUrl = "http://go.microsoft.com/fwlink/?LinkId=254433"; - - public const string ChinaManagementPortalUrl = "http://go.microsoft.com/fwlink/?LinkId=301902"; - - public const string AzureStorageEndpointSuffix = "core.windows.net"; - - public const string ChinaStorageEndpointSuffix = "core.chinacloudapi.cn"; - - public const string AzureSqlDatabaseDnsSuffix = ".database.windows.net"; - - public const string ChinaSqlDatabaseDnsSuffix = ".database.chinacloudapi.cn"; - - public const string AzureActiveDirectoryEndpoint = "https://login.windows.net/"; - - public const string ChinaActiveDirectoryEndpoint = "https://login.chinacloudapi.cn/"; - - public const string AzureGraphEndpoint = "https://graph.windows.net/"; - - public const string AzureTrafficManagerDnsSuffix = "trafficmanager.net"; - - public const string ChinaTrafficManagerDnsSuffix = "trafficmanager.cn"; - - public const string AzureKeyVaultDnsSuffix = "vault.azure.net"; - - public const string AzureKeyVaultServiceEndpointResourceId = "https://vault.azure.net"; - } -} \ No newline at end of file diff --git a/src/Common/Commands.Common/ComputeCloudException.cs b/src/Common/Commands.Common/ComputeCloudException.cs index fa8e55334e55..9d4e593b08e4 100644 --- a/src/Common/Commands.Common/ComputeCloudException.cs +++ b/src/Common/Commands.Common/ComputeCloudException.cs @@ -12,10 +12,10 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Hyak.Common; using System; using System.Linq; using System.Text; +using Hyak.Common; namespace Microsoft.WindowsAzure.Commands.Common { @@ -49,7 +49,7 @@ protected static string GetErrorMessageWithRequestIdInfo(CloudException cloudExc if (headers.ContainsKey(RequestIdHeaderInResponse)) { sb.AppendLine().AppendFormat( - Properties.Resources.ComputeCloudExceptionOperationIdMessage, + "OperationID : '{0}'", headers[RequestIdHeaderInResponse].FirstOrDefault()); } } diff --git a/src/Common/Commands.Common/DebugStreamTraceListener.cs b/src/Common/Commands.Common/DebugStreamTraceListener.cs index c17464d1f175..bae605aeff87 100644 --- a/src/Common/Commands.Common/DebugStreamTraceListener.cs +++ b/src/Common/Commands.Common/DebugStreamTraceListener.cs @@ -12,14 +12,8 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System; using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Diagnostics; -using System.IO; using Microsoft.IdentityModel.Clients.ActiveDirectory; namespace Microsoft.WindowsAzure.Commands.Common diff --git a/src/Common/Commands.Common/DiagnosticsHelper.cs b/src/Common/Commands.Common/DiagnosticsHelper.cs index 3b5a5007969c..50719b3c27f4 100644 --- a/src/Common/Commands.Common/DiagnosticsHelper.cs +++ b/src/Common/Commands.Common/DiagnosticsHelper.cs @@ -12,11 +12,9 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.WindowsAzure.Commands.Common.Properties; using System; using System.Collections; using System.IO; -using System.Linq; using System.Text; using System.Xml; using Newtonsoft.Json; @@ -57,18 +55,18 @@ public static Hashtable GetPublicDiagnosticsConfiguration(string config, string int wadCfgBeginIndex = config.IndexOf(""); if (wadCfgBeginIndex == -1) { - throw new ArgumentException(Resources.IaasDiagnosticsBadConfigNoWadCfg); + throw new ArgumentException("Cannot find the WadCfg element in the config."); } int wadCfgEndIndex = config.IndexOf(""); if (wadCfgEndIndex == -1) { - throw new ArgumentException(Resources.IaasDiagnosticsBadConfigNoEndWadCfg); + throw new ArgumentException("Cannot find the WadCfg end element in the config."); } if (wadCfgEndIndex <= wadCfgBeginIndex) { - throw new ArgumentException(Resources.IaasDiagnosticsBadConfigNoMatchingWadCfg); + throw new ArgumentException("WadCfg start element in the config is not matching the end element."); } string encodedConfiguration = Convert.ToBase64String( diff --git a/src/Common/Commands.Common/ErrorHelper.cs b/src/Common/Commands.Common/ErrorHelper.cs index 26cddb43a87a..3759d43d8282 100644 --- a/src/Common/Commands.Common/ErrorHelper.cs +++ b/src/Common/Commands.Common/ErrorHelper.cs @@ -12,12 +12,12 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.ServiceManagement.Model; using System.IO; using System.Net; using System.ServiceModel; using System.Xml; +using Microsoft.WindowsAzure.Commands.Common; +using Microsoft.WindowsAzure.Commands.ServiceManagement.Model; namespace Microsoft.WindowsAzure.Commands.Utilities.Common { diff --git a/src/Common/Commands.Common/GeneralUtilities.cs b/src/Common/Commands.Common/GeneralUtilities.cs index 8165caf16119..72c7921c13a3 100644 --- a/src/Common/Commands.Common/GeneralUtilities.cs +++ b/src/Common/Commands.Common/GeneralUtilities.cs @@ -12,9 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Hyak.Common; -using Microsoft.Azure.Common.Authentication; -using Microsoft.WindowsAzure.Commands.Common; using System; using System.Collections.Generic; using System.Diagnostics; @@ -25,10 +22,12 @@ using System.Net.Http.Headers; using System.Reflection; using System.Security.Cryptography.X509Certificates; -using System.Security.Permissions; using System.ServiceModel.Channels; using System.Text; using System.Xml; +using Hyak.Common; +using Microsoft.Azure.Common.Authentication; +using Microsoft.WindowsAzure.Commands.Common; namespace Microsoft.WindowsAzure.Commands.Utilities.Common { @@ -49,19 +48,6 @@ private static bool TryFindCertificatesInStore(string thumbprint, return certificates != null && certificates.Count > 0; } - public static string GetNodeModulesPath() - { - return Path.Combine( - FileUtilities.GetAssemblyDirectory(), - Microsoft.WindowsAzure.Commands.Common.Properties.Resources.NodeModulesPath); - } - - [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")] - public static void LaunchWebPage(string target) - { - ProcessHelper.Start(target); - } - public static X509Certificate2 GetCertificateFromStore(string thumbprint) { Validate.ValidateStringIsNullOrEmpty(thumbprint, "certificate thumbprint"); diff --git a/src/Common/Commands.Common/HttpClientExtensions.cs b/src/Common/Commands.Common/HttpClientExtensions.cs index 5f7e313644d2..4b75ea6ed796 100644 --- a/src/Common/Commands.Common/HttpClientExtensions.cs +++ b/src/Common/Commands.Common/HttpClientExtensions.cs @@ -13,13 +13,13 @@ // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Common.Authentication; -using Microsoft.WindowsAzure.Commands.Common; -using Newtonsoft.Json; using System; using System.Net; using System.Net.Http; using System.Net.Http.Headers; +using Microsoft.Azure.Common.Authentication; +using Microsoft.WindowsAzure.Commands.Common; +using Newtonsoft.Json; namespace Microsoft.WindowsAzure.Commands.Utilities.Common { diff --git a/src/Common/Commands.Common/ProfileClient.cs b/src/Common/Commands.Common/ProfileClient.cs new file mode 100644 index 000000000000..c4cb1476282a --- /dev/null +++ b/src/Common/Commands.Common/ProfileClient.cs @@ -0,0 +1,1158 @@ +// ---------------------------------------------------------------------------------- +// +// 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.Diagnostics; +using System.IO; +using System.Linq; +using System.Security; +using System.Security.Cryptography.X509Certificates; +using Hyak.Common; +using Microsoft.Azure.Common.Authentication.Factories; +using Microsoft.Azure.Common.Authentication.Models; +using Microsoft.Azure.Common.Authentication.Properties; +using Microsoft.WindowsAzure.Subscriptions; + +namespace Microsoft.Azure.Common.Authentication +{ + /// + /// Convenience client for azure profile and subscriptions. + /// + public class ProfileClient + { + public AzureSMProfile Profile { get; private set; } + + public Action WarningLog; + + public Action DebugLog; + + private void WriteDebugMessage(string message) + { + if (DebugLog != null) + { + DebugLog(message); + } + } + + private void WriteWarningMessage(string message) + { + if (WarningLog != null) + { + WarningLog(message); + } + } + + private void UpgradeProfile() + { + string oldProfileFilePath = Path.Combine(AzureSession.ProfileDirectory, AzureSession.OldProfileFile); + string oldProfileFilePathBackup = Path.Combine(AzureSession.ProfileDirectory, AzureSession.OldProfileFileBackup); + string newProfileFilePath = Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile); + if (AzureSession.DataStore.FileExists(oldProfileFilePath)) + { + string oldProfilePath = Path.Combine(AzureSession.ProfileDirectory, + AzureSession.OldProfileFile); + + try + { + // Try to backup old profile + try + { + AzureSession.DataStore.CopyFile(oldProfilePath, oldProfileFilePathBackup); + } + catch + { + // Ignore any errors here + } + + AzureSMProfile oldProfile = new AzureSMProfile(oldProfilePath); + + if (AzureSession.DataStore.FileExists(newProfileFilePath)) + { + // Merge profile files + AzureSMProfile newProfile = new AzureSMProfile(newProfileFilePath); + foreach (var environment in newProfile.Environments.Values) + { + oldProfile.Environments[environment.Name] = environment; + } + foreach (var subscription in newProfile.Subscriptions.Values) + { + oldProfile.Subscriptions[subscription.Id] = subscription; + } + AzureSession.DataStore.DeleteFile(newProfileFilePath); + } + + // If there were no load errors - delete backup file + if (oldProfile.ProfileLoadErrors.Count == 0) + { + try + { + AzureSession.DataStore.DeleteFile(oldProfileFilePathBackup); + } + catch + { + // Give up + } + } + + // Save the profile to the disk + oldProfile.Save(); + + // Rename WindowsAzureProfile.xml to WindowsAzureProfile.json + AzureSession.DataStore.RenameFile(oldProfilePath, newProfileFilePath); + + } + catch + { + // Something really bad happened - try to delete the old profile + try + { + AzureSession.DataStore.DeleteFile(oldProfilePath); + } + catch + { + // Ignore any errors + } + } + + // In case that we changed a disk profile, reload it + if (Profile != null && Profile.ProfilePath == newProfileFilePath) + { + Profile = new AzureSMProfile(Profile.ProfilePath); + } + } + } + + public ProfileClient(AzureSMProfile profile) + { + Profile = profile; + WarningLog = (s) => Debug.WriteLine(s); + + try + { + UpgradeProfile(); + } + catch + { + // Should never fail in constructor + } + } + + #region Profile management + + /// + /// Initializes AzureSMProfile using passed in certificate. The certificate + /// is imported into a certificate store. + /// + /// Environment object. + /// Subscription Id + /// Certificate to use with profile. + /// Storage account name (optional). + /// + public void InitializeProfile(AzureEnvironment environment, Guid subscriptionId, X509Certificate2 certificate, + string storageAccount) + { + if (environment == null) + { + throw new ArgumentNullException("environment"); + } + if (certificate == null) + { + throw new ArgumentNullException("certificate"); + } + + // Add environment if not public + if (!AzureEnvironment.PublicEnvironments.ContainsKey(environment.Name)) + { + AddOrSetEnvironment(environment); + } + + // Add account + var azureAccount = new AzureAccount + { + Id = certificate.Thumbprint, + Type = AzureAccount.AccountType.Certificate + }; + azureAccount.Properties[AzureAccount.Property.Subscriptions] = subscriptionId.ToString(); + ImportCertificate(certificate); + AddOrSetAccount(azureAccount); + + // Add subscription + var azureSubscription = new AzureSubscription + { + Id = subscriptionId, + Name = subscriptionId.ToString(), + Environment = environment.Name + }; + if (!string.IsNullOrEmpty(storageAccount)) + { + azureSubscription.Properties[AzureSubscription.Property.StorageAccount] = storageAccount; + } + azureSubscription.Properties[AzureSubscription.Property.Default] = "True"; + azureSubscription.Account = certificate.Thumbprint; + AddOrSetSubscription(azureSubscription); + } + + /// + /// Initializes AzureSMProfile using passed in access token. + /// + /// Environment object. + /// Subscription Id + /// AccessToken to use with profile. + /// AccountId for the new account. + /// Storage account name (optional). + /// + public void InitializeProfile(AzureEnvironment environment, Guid subscriptionId, string accessToken, + string accountId, string storageAccount) + { + if (environment == null) + { + throw new ArgumentNullException("environment"); + } + if (accessToken == null) + { + throw new ArgumentNullException("accessToken"); + } + + // Add environment if not public + if (!AzureEnvironment.PublicEnvironments.ContainsKey(environment.Name)) + { + AddOrSetEnvironment(environment); + } + + // Add account + var azureAccount = new AzureAccount + { + Id = accountId, + Type = AzureAccount.AccountType.AccessToken + }; + azureAccount.Properties[AzureAccount.Property.Subscriptions] = subscriptionId.ToString(); + azureAccount.Properties[AzureAccount.Property.AccessToken] = accessToken; + AddOrSetAccount(azureAccount); + + // Add subscription + var azureSubscription = new AzureSubscription + { + Id = subscriptionId, + Name = subscriptionId.ToString(), + Environment = environment.Name + }; + if (!string.IsNullOrEmpty(storageAccount)) + { + azureSubscription.Properties[AzureSubscription.Property.StorageAccount] = storageAccount; + } + azureSubscription.Properties[AzureSubscription.Property.Default] = "True"; + azureSubscription.Account = accountId; + AddOrSetSubscription(azureSubscription); + } + + /// + /// Initializes AzureSMProfile using passed in account and optional password. + /// + /// Environment object. + /// Subscription Id + /// Azure account with AD username and tenant. + /// AD password (optional). + /// Storage account name (optional). + /// + public void InitializeProfile(AzureEnvironment environment, Guid subscriptionId, AzureAccount account, + SecureString password, string storageAccount) + { + if (environment == null) + { + throw new ArgumentNullException("environment"); + } + if (account == null) + { + throw new ArgumentNullException("account"); + } + + // Add environment if not public + if (!AzureEnvironment.PublicEnvironments.ContainsKey(environment.Name)) + { + AddOrSetEnvironment(environment); + } + + // Add account + var azureAccount = AddAccountAndLoadSubscriptions(account, environment, password); + + // Add subscription + if (!azureAccount.HasSubscription(subscriptionId)) + { + throw new ArgumentException(string.Format(Resources.SubscriptionIdNotFoundMessage, subscriptionId)); + } + var azureSubscription = GetSubscription(subscriptionId); + if (!string.IsNullOrEmpty(storageAccount)) + { + azureSubscription.Properties[AzureSubscription.Property.StorageAccount] = storageAccount; + } + AddOrSetSubscription(azureSubscription); + } + #endregion + + #region Account management + + public AzureAccount AddAccountAndLoadSubscriptions(AzureAccount account, AzureEnvironment environment, SecureString password) + { + if (environment == null) + { + throw new ArgumentNullException("environment"); + } + + if (account == null) + { + throw new ArgumentNullException("account"); + } + + var subscriptionsFromServer = ListSubscriptionsFromServer( + account, + environment, + password, + password == null ? ShowDialog.Always : ShowDialog.Never).ToList(); + + // If account id is null the login failed + if (account.Id != null) + { + // Update back Profile.Subscriptions + foreach (var subscription in subscriptionsFromServer) + { + AddOrSetSubscription(subscription); + } + + if (Profile.DefaultSubscription == null) + { + var firstSubscription = Profile.Subscriptions.Values.FirstOrDefault(); + if (firstSubscription != null) + { + SetSubscriptionAsDefault(firstSubscription.Name, firstSubscription.Account); + } + } + + return Profile.Accounts[account.Id]; + } + else + { + return null; + } + } + + public AzureAccount AddOrSetAccount(AzureAccount account) + { + if (account == null) + { + throw new ArgumentNullException("account", Resources.AccountNeedsToBeSpecified); + } + + if (Profile.Accounts.ContainsKey(account.Id)) + { + Profile.Accounts[account.Id] = + MergeAccountProperties(account, Profile.Accounts[account.Id]); + } + else + { + Profile.Accounts[account.Id] = account; + } + + return Profile.Accounts[account.Id]; + } + + public AzureAccount GetAccountOrDefault(string accountName) + { + if (string.IsNullOrEmpty(accountName)) + { + return Profile.DefaultContext.Account; + } + else if (Profile.Accounts.ContainsKey(accountName)) + { + return Profile.Accounts[accountName]; + } + else + { + throw new ArgumentException(string.Format("Account with name '{0}' does not exist.", accountName), "accountName"); + } + } + + public AzureAccount GetAccountOrNull(string accountName) + { + if (string.IsNullOrEmpty(accountName)) + { + throw new ArgumentNullException("accountName"); + } + + if (Profile.Accounts.ContainsKey(accountName)) + { + return Profile.Accounts[accountName]; + } + else + { + return null; + } + } + + public AzureAccount GetAccount(string accountName) + { + var account = GetAccountOrNull(accountName); + + if (account == null) + { + throw new ArgumentException(string.Format("Account with name '{0}' does not exist.", accountName), "accountName"); + } + + return account; + } + + public IEnumerable ListAccounts(string accountName) + { + List accounts = new List(); + + if (!string.IsNullOrEmpty(accountName)) + { + if (Profile.Accounts.ContainsKey(accountName)) + { + accounts.Add(Profile.Accounts[accountName]); + } + } + else + { + accounts = Profile.Accounts.Values.ToList(); + } + + return accounts; + } + + public AzureAccount RemoveAccount(string accountId) + { + if (string.IsNullOrEmpty(accountId)) + { + throw new ArgumentNullException("accountId", Resources.UserNameNeedsToBeSpecified); + } + + if (!Profile.Accounts.ContainsKey(accountId)) + { + throw new ArgumentException(Resources.UserNameIsNotValid, "accountId"); + } + + AzureAccount account = Profile.Accounts[accountId]; + Profile.Accounts.Remove(account.Id); + + foreach (AzureSubscription subscription in account.GetSubscriptions(Profile).ToArray()) + { + if (string.Equals(subscription.Account, accountId, StringComparison.InvariantCultureIgnoreCase)) + { + AzureAccount remainingAccount = GetSubscriptionAccount(subscription.Id); + // There's no default account to use, remove the subscription. + if (remainingAccount == null) + { + // Warn the user if the removed subscription is the default one. + if (subscription.IsPropertySet(AzureSubscription.Property.Default)) + { + Debug.Assert(subscription.Equals(Profile.DefaultSubscription)); + WriteWarningMessage(Resources.RemoveDefaultSubscription); + } + + Profile.Subscriptions.Remove(subscription.Id); + } + else + { + subscription.Account = remainingAccount.Id; + AddOrSetSubscription(subscription); + } + } + } + + return account; + } + + private AzureAccount GetSubscriptionAccount(Guid subscriptionId) + { + List accounts = ListSubscriptionAccounts(subscriptionId); + AzureAccount account = accounts.FirstOrDefault(a => a.Type != AzureAccount.AccountType.Certificate); + + if (account != null) + { + // Found a non-certificate account. + return account; + } + + // Use certificate account if its there. + account = accounts.FirstOrDefault(); + + return account; + } + + #endregion + + #region Subscription management + + public AzureSubscription AddOrSetSubscription(AzureSubscription subscription) + { + if (subscription == null) + { + throw new ArgumentNullException("subscription", Resources.SubscriptionNeedsToBeSpecified); + } + if (subscription.Environment == null) + { + throw new ArgumentNullException("subscription.Environment", Resources.EnvironmentNeedsToBeSpecified); + } + // Validate environment + GetEnvironmentOrDefault(subscription.Environment); + + if (Profile.Subscriptions.ContainsKey(subscription.Id)) + { + Profile.Subscriptions[subscription.Id] = MergeSubscriptionProperties(subscription, Profile.Subscriptions[subscription.Id]); + } + else + { + Debug.Assert(!string.IsNullOrEmpty(subscription.Account)); + if (!Profile.Accounts.ContainsKey(subscription.Account)) + { + throw new KeyNotFoundException(string.Format("The specified account {0} does not exist in profile accounts", subscription.Account)); + } + + Profile.Subscriptions[subscription.Id] = subscription; + } + + return Profile.Subscriptions[subscription.Id]; + } + + public AzureSubscription RemoveSubscription(string name) + { + if (string.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name", Resources.SubscriptionNameNeedsToBeSpecified); + } + + var subscription = Profile.Subscriptions.Values.FirstOrDefault(s => s.Name == name); + + if (subscription == null) + { + throw new ArgumentException(string.Format(Resources.SubscriptionNameNotFoundMessage, name), "name"); + } + else + { + return RemoveSubscription(subscription.Id); + } + } + + public AzureSubscription RemoveSubscription(Guid id) + { + if (!Profile.Subscriptions.ContainsKey(id)) + { + throw new ArgumentException(string.Format(Resources.SubscriptionIdNotFoundMessage, id), "id"); + } + + var subscription = Profile.Subscriptions[id]; + + if (subscription.IsPropertySet(AzureSubscription.Property.Default)) + { + Debug.Assert(Profile.DefaultSubscription == subscription); + WriteWarningMessage(Resources.RemoveDefaultSubscription); + } + + Profile.Subscriptions.Remove(id); + + // Remove this subscription from its associated AzureAccounts + List accounts = ListSubscriptionAccounts(id); + + foreach (AzureAccount account in accounts) + { + account.RemoveSubscription(id); + if (!account.IsPropertySet(AzureAccount.Property.Subscriptions)) + { + Profile.Accounts.Remove(account.Id); + } + } + + return subscription; + } + + public List RefreshSubscriptions(AzureEnvironment environment) + { + if (environment == null) + { + throw new ArgumentNullException("environment"); + } + + var subscriptionsFromServer = ListSubscriptionsFromServerForAllAccounts(environment); + + // Update back Profile.Subscriptions + foreach (var subscription in subscriptionsFromServer) + { + // Resetting back default account + if (Profile.Subscriptions.ContainsKey(subscription.Id)) + { + subscription.Account = Profile.Subscriptions[subscription.Id].Account; + } + AddOrSetSubscription(subscription); + } + + return Profile.Subscriptions.Values.ToList(); + } + + public AzureSubscription GetSubscription(Guid id) + { + if (Profile.Subscriptions.ContainsKey(id)) + { + return Profile.Subscriptions[id]; + } + else + { + throw new ArgumentException(string.Format(Resources.SubscriptionIdNotFoundMessage, id), "id"); + } + } + + public AzureSubscription GetSubscription(string name) + { + AzureSubscription subscription = Profile.Subscriptions.Values + .FirstOrDefault(s => s.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); + + if (subscription != null) + { + return subscription; + } + else + { + throw new ArgumentException(string.Format(Resources.SubscriptionNameNotFoundMessage, name), "name"); + } + } + + public AzureSubscription SetSubscriptionAsDefault(string name, string accountName) + { + if (name == null) + { + throw new ArgumentException(string.Format(Resources.InvalidSubscriptionName, name), "name"); + } + + var subscription = Profile.Subscriptions.Values.FirstOrDefault(s => s.Name == name); + + if (subscription == null) + { + throw new ArgumentException(string.Format(Resources.SubscriptionNameNotFoundMessage, name), "name"); + } + + return SetSubscriptionAsDefault(subscription.Id, accountName); + } + + public AzureSubscription SetSubscriptionAsDefault(Guid id, string accountName) + { + AzureSubscription subscription = GetSubscription(id); + + if (subscription != null) + { + Profile.DefaultSubscription = subscription; + Profile.DefaultSubscription.Account = accountName; + } + + return subscription; + } + + public void ClearAll() + { + Profile.Accounts.Clear(); + Profile.DefaultSubscription = null; + Profile.Environments.Clear(); + Profile.Subscriptions.Clear(); + Profile.Save(); + + AzureSession.TokenCache.Clear(); + } + + public void ClearDefaultSubscription() + { + Profile.DefaultSubscription = null; + } + + public void ImportCertificate(X509Certificate2 certificate) + { + AzureSession.DataStore.AddCertificate(certificate); + } + + public List ListSubscriptionAccounts(Guid subscriptionId) + { + return Profile.Accounts.Where(a => a.Value.HasSubscription(subscriptionId)) + .Select(a => a.Value).ToList(); + } + + public List ImportPublishSettings(string filePath, string environmentName) + { + var subscriptions = ListSubscriptionsFromPublishSettingsFile(filePath, environmentName); + if (subscriptions.Any()) + { + foreach (var subscription in subscriptions) + { + AzureAccount account = new AzureAccount + { + Id = subscription.Account, + Type = AzureAccount.AccountType.Certificate + }; + account.SetOrAppendProperty(AzureAccount.Property.Subscriptions, subscription.Id.ToString()); + AddOrSetAccount(account); + + if (!Profile.Subscriptions.ContainsKey(subscription.Id)) + { + AddOrSetSubscription(subscription); + } + + if (Profile.DefaultSubscription == null) + { + Profile.DefaultSubscription = subscription; + } + } + } + return subscriptions; + } + + private List ListSubscriptionsFromPublishSettingsFile(string filePath, string environment) + { + if (string.IsNullOrEmpty(filePath) || !AzureSession.DataStore.FileExists(filePath)) + { + throw new ArgumentException(Resources.FilePathIsNotValid, "filePath"); + } + return PublishSettingsImporter.ImportAzureSubscription(AzureSession.DataStore.ReadFileAsStream(filePath), this, environment).ToList(); + } + + private IEnumerable ListSubscriptionsFromServerForAllAccounts(AzureEnvironment environment) + { + // Get all AD accounts and iterate + var accountNames = Profile.Accounts.Keys; + + List subscriptions = new List(); + + foreach (var accountName in accountNames.ToArray()) + { + var account = Profile.Accounts[accountName]; + + if (account.Type != AzureAccount.AccountType.Certificate) + { + subscriptions.AddRange(ListSubscriptionsFromServer(account, environment, null, ShowDialog.Never)); + } + + AddOrSetAccount(account); + } + + if (subscriptions.Any()) + { + return subscriptions; + } + else + { + return new AzureSubscription[0]; + } + } + + private IEnumerable ListSubscriptionsFromServer(AzureAccount account, AzureEnvironment environment, SecureString password, ShowDialog promptBehavior) + { + string[] tenants = null; + try + { + if (!account.IsPropertySet(AzureAccount.Property.Tenants)) + { + tenants = LoadAccountTenants(account, environment, password, promptBehavior); + } + else + { + var storedTenants = account.GetPropertyAsArray(AzureAccount.Property.Tenants); + if (account.Type == AzureAccount.AccountType.User && storedTenants.Count() == 1) + { + TracingAdapter.Information(Resources.AuthenticatingForSingleTenant, account.Id, storedTenants[0]); + AzureSession.AuthenticationFactory.Authenticate(account, environment, storedTenants[0], password, + promptBehavior); + } + } + } + catch (AadAuthenticationException aadEx) + { + WriteOrThrowAadExceptionMessage(aadEx); + return new AzureSubscription[0]; + } + + try + { + tenants = tenants ?? account.GetPropertyAsArray(AzureAccount.Property.Tenants); + List rdfeSubscriptions = ListServiceManagementSubscriptions(account, environment, + password, ShowDialog.Never, tenants).ToList(); + + // Set user ID + foreach (var subscription in rdfeSubscriptions) + { + account.SetOrAppendProperty(AzureAccount.Property.Subscriptions, subscription.Id.ToString()); + } + + if (rdfeSubscriptions.Any()) + { + return rdfeSubscriptions; + } + else + { + return new AzureSubscription[0]; + } + } + catch (AadAuthenticationException aadEx) + { + WriteOrThrowAadExceptionMessage(aadEx); + return new AzureSubscription[0]; + } + } + + private string[] LoadAccountTenants(AzureAccount account, AzureEnvironment environment, SecureString password, ShowDialog promptBehavior) + { + var commonTenantToken = AzureSession.AuthenticationFactory.Authenticate(account, environment, + AuthenticationFactory.CommonAdTenant, password, promptBehavior); + + using (SubscriptionClient SubscriptionClient = AzureSession.ClientFactory + .CreateCustomClient( + new TokenCloudCredentials(commonTenantToken.AccessToken), + environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement))) + { + var subscriptionListResult = SubscriptionClient.Subscriptions.List(); + return subscriptionListResult.Subscriptions.Select(s => s.ActiveDirectoryTenantId).Distinct().ToArray(); + } + } + + private AzureSubscription MergeSubscriptionProperties(AzureSubscription subscription1, AzureSubscription subscription2) + { + if (subscription1 == null || subscription2 == null) + { + throw new ArgumentNullException("subscription1"); + } + if (subscription1.Id != subscription2.Id) + { + throw new ArgumentException("Subscription Ids do not match."); + } + AzureSubscription mergedSubscription = new AzureSubscription + { + Id = subscription1.Id, + Name = subscription1.Name, + Environment = subscription1.Environment, + Account = subscription1.Account ?? subscription2.Account + }; + + // Merge all properties + foreach (AzureSubscription.Property property in Enum.GetValues(typeof(AzureSubscription.Property))) + { + string propertyValue = subscription1.GetProperty(property) ?? subscription2.GetProperty(property); + if (propertyValue != null) + { + mergedSubscription.Properties[property] = propertyValue; + } + } + + // Merge RegisteredResourceProviders + var registeredProviders = subscription1.GetPropertyAsArray(AzureSubscription.Property.RegisteredResourceProviders) + .Union(subscription2.GetPropertyAsArray(AzureSubscription.Property.RegisteredResourceProviders), StringComparer.CurrentCultureIgnoreCase); + + mergedSubscription.SetProperty(AzureSubscription.Property.RegisteredResourceProviders, registeredProviders.ToArray()); + + // Merge Tenants + var tenants = subscription1.GetPropertyAsArray(AzureSubscription.Property.Tenants) + .Union(subscription2.GetPropertyAsArray(AzureSubscription.Property.Tenants), StringComparer.CurrentCultureIgnoreCase); + + mergedSubscription.SetProperty(AzureSubscription.Property.Tenants, tenants.ToArray()); + + return mergedSubscription; + } + + private AzureEnvironment MergeEnvironmentProperties(AzureEnvironment environment1, AzureEnvironment environment2) + { + if (environment1 == null || environment2 == null) + { + throw new ArgumentNullException("environment1"); + } + if (!string.Equals(environment1.Name, environment2.Name, StringComparison.InvariantCultureIgnoreCase)) + { + throw new ArgumentException("Environment names do not match."); + } + AzureEnvironment mergedEnvironment = new AzureEnvironment + { + Name = environment1.Name + }; + + // Merge all properties + foreach (AzureEnvironment.Endpoint property in Enum.GetValues(typeof(AzureEnvironment.Endpoint))) + { + string propertyValue = environment1.GetEndpoint(property) ?? environment2.GetEndpoint(property); + if (propertyValue != null) + { + mergedEnvironment.Endpoints[property] = propertyValue; + } + } + + return mergedEnvironment; + } + + private AzureAccount MergeAccountProperties(AzureAccount account1, AzureAccount account2) + { + if (account1 == null || account2 == null) + { + throw new ArgumentNullException("account1"); + } + if (!string.Equals(account1.Id, account2.Id, StringComparison.InvariantCultureIgnoreCase)) + { + throw new ArgumentException("Account Ids do not match."); + } + if (account1.Type != account2.Type) + { + throw new ArgumentException("Account1 types do not match."); + } + AzureAccount mergeAccount = new AzureAccount + { + Id = account1.Id, + Type = account1.Type + }; + + // Merge all properties + foreach (AzureAccount.Property property in Enum.GetValues(typeof(AzureAccount.Property))) + { + string propertyValue = account1.GetProperty(property) ?? account2.GetProperty(property); + if (propertyValue != null) + { + mergeAccount.Properties[property] = propertyValue; + } + } + + // Merge Tenants + var tenants = account1.GetPropertyAsArray(AzureAccount.Property.Tenants) + .Union(account2.GetPropertyAsArray(AzureAccount.Property.Tenants), StringComparer.CurrentCultureIgnoreCase); + + mergeAccount.SetProperty(AzureAccount.Property.Tenants, tenants.ToArray()); + + // Merge Subscriptions + var subscriptions = account1.GetPropertyAsArray(AzureAccount.Property.Subscriptions) + .Union(account2.GetPropertyAsArray(AzureAccount.Property.Subscriptions), StringComparer.CurrentCultureIgnoreCase); + + mergeAccount.SetProperty(AzureAccount.Property.Subscriptions, subscriptions.ToArray()); + + return mergeAccount; + } + + private void CopyAccount(AzureAccount sourceAccount, AzureAccount targetAccount) + { + targetAccount.Id = sourceAccount.Id; + targetAccount.Type = sourceAccount.Type; + } + + private IEnumerable ListServiceManagementSubscriptions(AzureAccount account, AzureEnvironment environment, SecureString password, ShowDialog promptBehavior, string[] tenants) + { + List result = new List(); + + if (!environment.IsEndpointSet(AzureEnvironment.Endpoint.ServiceManagement)) + { + return result; + } + + foreach (var tenant in tenants) + { + try + { + var tenantAccount = new AzureAccount(); + CopyAccount(account, tenantAccount); + var tenantToken = AzureSession.AuthenticationFactory.Authenticate(tenantAccount, environment, tenant, password, ShowDialog.Never); + if (string.Equals(tenantAccount.Id, account.Id, StringComparison.InvariantCultureIgnoreCase)) + { + tenantAccount = account; + } + + tenantAccount.SetOrAppendProperty(AzureAccount.Property.Tenants, new string[] { tenant }); + using (var subscriptionClient = AzureSession.ClientFactory.CreateCustomClient( + new TokenCloudCredentials(tenantToken.AccessToken), + environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement))) + { + var subscriptionListResult = subscriptionClient.Subscriptions.List(); + foreach (var subscription in subscriptionListResult.Subscriptions) + { + // only add the subscription if it's actually in this tenant + if (subscription.ActiveDirectoryTenantId == tenant) + { + AzureSubscription psSubscription = new AzureSubscription + { + Id = new Guid(subscription.SubscriptionId), + Name = subscription.SubscriptionName, + Environment = environment.Name + }; + psSubscription.SetProperty(AzureSubscription.Property.Tenants, + subscription.ActiveDirectoryTenantId); + psSubscription.Account = tenantAccount.Id; + tenantAccount.SetOrAppendProperty(AzureAccount.Property.Subscriptions, + new string[] { psSubscription.Id.ToString() }); + result.Add(psSubscription); + } + } + } + + AddOrSetAccount(tenantAccount); + } + catch (CloudException cEx) + { + WriteOrThrowAadExceptionMessage(cEx); + } + catch (AadAuthenticationException aadEx) + { + WriteOrThrowAadExceptionMessage(aadEx); + } + } + + return result; + } + + private void WriteOrThrowAadExceptionMessage(AadAuthenticationException aadEx) + { + if (aadEx is AadAuthenticationFailedWithoutPopupException) + { + WriteDebugMessage(aadEx.Message); + } + else if (aadEx is AadAuthenticationCanceledException) + { + WriteWarningMessage(aadEx.Message); + } + else + { + throw aadEx; + } + } + + private void WriteOrThrowAadExceptionMessage(CloudException aadEx) + { + WriteDebugMessage(aadEx.Message); + } + + #endregion + + #region Environment management + + public AzureEnvironment GetEnvironmentOrDefault(string name) + { + if (string.IsNullOrEmpty(name) && + Profile.DefaultSubscription == null) + { + return AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud]; + } + else if (string.IsNullOrEmpty(name) && + Profile.DefaultSubscription != null) + { + return Profile.DefaultContext.Environment; + } + else if (Profile.Environments.ContainsKey(name)) + { + return Profile.Environments[name]; + } + else + { + throw new ArgumentException(string.Format(Resources.EnvironmentNotFound, name)); + } + } + + public AzureEnvironment GetEnvironment(string name, string serviceEndpoint, string resourceEndpoint) + { + if (serviceEndpoint == null) + { + // Set to invalid value + serviceEndpoint = Guid.NewGuid().ToString(); + } + + if (resourceEndpoint == null) + { + // Set to invalid value + resourceEndpoint = Guid.NewGuid().ToString(); + } + + if (name != null) + { + if (Profile.Environments.ContainsKey(name)) + { + return Profile.Environments[name]; + } + else + { + return null; + } + } + else + { + return Profile.Environments.Values.FirstOrDefault(e => + e.IsEndpointSetToValue(AzureEnvironment.Endpoint.ServiceManagement, serviceEndpoint) || + e.IsEndpointSetToValue(AzureEnvironment.Endpoint.ResourceManager, resourceEndpoint)); + } + } + + public List ListEnvironments(string name) + { + if (string.IsNullOrEmpty(name)) + { + return Profile.Environments.Values.ToList(); + } + else if (Profile.Environments.ContainsKey(name)) + { + return new[] { Profile.Environments[name] }.ToList(); + } + else + { + return new AzureEnvironment[0].ToList(); + } + } + + public AzureEnvironment RemoveEnvironment(string name) + { + if (string.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name", Resources.EnvironmentNameNeedsToBeSpecified); + } + if (AzureEnvironment.PublicEnvironments.ContainsKey(name)) + { + throw new ArgumentException(Resources.RemovingDefaultEnvironmentsNotSupported, "name"); + } + + if (Profile.Environments.ContainsKey(name)) + { + var environment = Profile.Environments[name]; + var subscriptions = Profile.Subscriptions.Values.Where(s => s.Environment == name).ToArray(); + foreach (var subscription in subscriptions) + { + RemoveSubscription(subscription.Id); + } + Profile.Environments.Remove(name); + return environment; + } + else + { + throw new ArgumentException(string.Format(Resources.EnvironmentNotFound, name), "name"); + } + } + + public AzureEnvironment AddOrSetEnvironment(AzureEnvironment environment) + { + if (environment == null) + { + throw new ArgumentNullException("environment", Resources.EnvironmentNeedsToBeSpecified); + } + + if (AzureEnvironment.PublicEnvironments.ContainsKey(environment.Name)) + { + throw new ArgumentException(Resources.ChangingDefaultEnvironmentNotSupported, "environment"); + } + + if (Profile.Environments.ContainsKey(environment.Name)) + { + Profile.Environments[environment.Name] = + MergeEnvironmentProperties(environment, Profile.Environments[environment.Name]); + } + else + { + Profile.Environments[environment.Name] = environment; + } + + return Profile.Environments[environment.Name]; + } + #endregion + } +} \ No newline at end of file diff --git a/src/Common/Commands.Common/Properties/Resources.Designer.cs b/src/Common/Commands.Common/Properties/Resources.Designer.cs index 0ed4db8b136b..f8141354414e 100644 --- a/src/Common/Commands.Common/Properties/Resources.Designer.cs +++ b/src/Common/Commands.Common/Properties/Resources.Designer.cs @@ -8,10 +8,10 @@ // //------------------------------------------------------------------------------ -namespace Microsoft.WindowsAzure.Commands.Common.Properties { - using System; - - +namespace Microsoft.WindowsAzure.Commands.Common.Properties +{ + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// diff --git a/src/Common/Commands.Common/PublishSettingsImporter.cs b/src/Common/Commands.Common/PublishSettingsImporter.cs new file mode 100644 index 000000000000..1839624ec0c1 --- /dev/null +++ b/src/Common/Commands.Common/PublishSettingsImporter.cs @@ -0,0 +1,95 @@ +// ---------------------------------------------------------------------------------- +// +// 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.IO; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Xml.Serialization; +using Microsoft.Azure.Common.Authentication.Models; +using Microsoft.Azure.Common.Authentication.XmlSchema; + +namespace Microsoft.Azure.Common.Authentication +{ + /// + /// Class that handles loading publishsettings files + /// and turning them into AzureSubscription objects. + /// + public static class PublishSettingsImporter + { + public static IEnumerable ImportAzureSubscription(Stream stream, ProfileClient azureProfileClient, string environment) + { + var publishData = DeserializePublishData(stream); + PublishDataPublishProfile profile = publishData.Items.Single(); + stream.Close(); + return profile.Subscription.Select(s => PublishSubscriptionToAzureSubscription(azureProfileClient, profile, s, environment)); + } + + private static PublishData DeserializePublishData(Stream stream) + { + var serializer = new XmlSerializer(typeof(PublishData)); + return (PublishData)serializer.Deserialize(stream); + } + + private static AzureSubscription PublishSubscriptionToAzureSubscription( + ProfileClient azureProfileClient, + PublishDataPublishProfile profile, + PublishDataPublishProfileSubscription s, + string environment) + { + var certificate = GetCertificate(profile, s); + + if (string.IsNullOrEmpty(environment)) + { + var azureEnvironment = azureProfileClient.GetEnvironment(environment, s.ServiceManagementUrl ?? profile.Url, null); + if (azureEnvironment != null) + { + environment = azureEnvironment.Name; + } + else + { + environment = EnvironmentName.AzureCloud; + } + } + + return new AzureSubscription + { + Id = new Guid(s.Id), + Name = s.Name, + Environment = environment, + Account = certificate.Thumbprint + }; + } + + private static X509Certificate2 GetCertificate(PublishDataPublishProfile profile, + PublishDataPublishProfileSubscription s) + { + string certificateString; + if (!string.IsNullOrEmpty(s.ManagementCertificate)) + { + certificateString = s.ManagementCertificate; + } + else + { + certificateString = profile.ManagementCertificate; + } + + X509Certificate2 certificate = new X509Certificate2(Convert.FromBase64String(certificateString), string.Empty); + AzureSession.DataStore.AddCertificate(certificate); + + return certificate; + } + } +} diff --git a/src/Common/Commands.Common/RPRegistrationAction.cs b/src/Common/Commands.Common/RPRegistrationAction.cs new file mode 100644 index 000000000000..fa6bd4f4d09d --- /dev/null +++ b/src/Common/Commands.Common/RPRegistrationAction.cs @@ -0,0 +1,151 @@ +// ---------------------------------------------------------------------------------- +// +// 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.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Net; +using Hyak.Common; +using Microsoft.Azure.Management.Resources; +using Microsoft.WindowsAzure.Management; + +namespace Microsoft.Azure.Common.Authentication.Models +{ + public class RPRegistrationAction : IClientAction + { + /// + /// Registers resource providers for Sparta. + /// + /// The client type + private void RegisterResourceManagerProviders(IAzureProfile profile) + { + var providersToRegister = RequiredResourceLookup.RequiredProvidersForResourceManager(); + var registeredProviders = profile.DefaultContext.Subscription.GetPropertyAsArray(AzureSubscription.Property.RegisteredResourceProviders); + var unregisteredProviders = providersToRegister.Where(p => !registeredProviders.Contains(p)).ToList(); + var successfullyRegisteredProvider = new List(); + SubscriptionCloudCredentials creds = AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(profile.DefaultContext); + + if (unregisteredProviders.Count > 0) + { + using (var client = ClientFactory.CreateCustomClient( + creds, + profile.DefaultContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager))) + { + foreach (string provider in unregisteredProviders) + { + try + { + client.Providers.Register(provider); + successfullyRegisteredProvider.Add(provider); + } + catch + { + // Ignore this as the user may not have access to service management endpoint or the provider is already registered + } + } + } + } + } + + /// + /// Registers resource providers for RDFE. + /// + /// The client type + private void RegisterServiceManagementProviders(AzureSMProfile profile) + { + var credentials = AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(profile.DefaultContext); + var providersToRegister = RequiredResourceLookup.RequiredProvidersForServiceManagement(); + var registeredProviders = profile.DefaultContext.Subscription.GetPropertyAsArray(AzureSubscription.Property.RegisteredResourceProviders); + var unregisteredProviders = providersToRegister.Where(p => !registeredProviders.Contains(p)).ToList(); + var successfullyRegisteredProvider = new List(); + + if (unregisteredProviders.Count > 0) + { + using (var client = new ManagementClient( + credentials, + profile.DefaultContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement))) + { + foreach (var provider in unregisteredProviders) + { + try + { + client.Subscriptions.RegisterResource(provider); + } + catch (CloudException ex) + { + if (ex.Response.StatusCode != HttpStatusCode.Conflict && ex.Response.StatusCode != HttpStatusCode.NotFound) + { + // Conflict means already registered, that's OK. + // NotFound means there is no registration support, like Windows Azure Pack. + // Otherwise it's a failure. + throw; + } + } + successfullyRegisteredProvider.Add(provider); + } + } + + Debug.Assert(profile is AzureSMProfile); + UpdateSubscriptionRegisteredProviders((AzureSMProfile)profile, profile.DefaultContext.Subscription, successfullyRegisteredProvider); + } + } + + private void UpdateSubscriptionRegisteredProviders(AzureSMProfile profile, AzureSubscription subscription, List providers) + { + if (providers != null && providers.Count > 0) + { + subscription.SetOrAppendProperty(AzureSubscription.Property.RegisteredResourceProviders, + providers.ToArray()); + try + { + ProfileClient profileClient = new ProfileClient(profile); + 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 + } + } + } + + public void Apply(TClient client, AzureSMProfile profile, AzureEnvironment.Endpoint endpoint) where TClient : ServiceClient + { + Debug.Assert(ClientFactory != null); + + if (endpoint == AzureEnvironment.Endpoint.ServiceManagement) + { + RegisterServiceManagementProviders(profile); + } + else if (endpoint == AzureEnvironment.Endpoint.ResourceManager) + { + RegisterResourceManagerProviders(profile); + } + } + + public IClientFactory ClientFactory { get; set; } + + + public void ApplyArm(TClient client, AzureRMProfile profile, AzureEnvironment.Endpoint endpoint) where TClient : Rest.ServiceClient + { + Debug.Assert(ClientFactory != null); + + if (endpoint == AzureEnvironment.Endpoint.ResourceManager) + { + RegisterResourceManagerProviders(profile); + } + } + } +} diff --git a/src/Common/Commands.Common/RecordingTracingInterceptor.cs b/src/Common/Commands.Common/RecordingTracingInterceptor.cs index 9081356f5f98..ec8400ceb089 100644 --- a/src/Common/Commands.Common/RecordingTracingInterceptor.cs +++ b/src/Common/Commands.Common/RecordingTracingInterceptor.cs @@ -12,13 +12,12 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Hyak.Common; -using Microsoft.WindowsAzure; -using Microsoft.WindowsAzure.Commands.Utilities.Common; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Net.Http; +using Hyak.Common; +using Microsoft.WindowsAzure.Commands.Utilities.Common; namespace Microsoft.Azure.Common.Authentication.Models { diff --git a/src/Common/Commands.Common/RequiredResourceLookup.cs b/src/Common/Commands.Common/RequiredResourceLookup.cs new file mode 100644 index 000000000000..3feeb78e7526 --- /dev/null +++ b/src/Common/Commands.Common/RequiredResourceLookup.cs @@ -0,0 +1,102 @@ +// ---------------------------------------------------------------------------------- +// +// 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.Collections.Generic; + +namespace Microsoft.Azure.Common.Authentication +{ + /// + /// This class handles mapping management client types + /// to the corresponding required resource provider names. + /// + internal static class RequiredResourceLookup + { + private const string BatchProviderNamespace = "microsoft.batch"; + private const string CacheProviderNamespace = "microsoft.cache"; + private const string ComputeProviderNamespace = "Microsoft.Compute"; + private const string DataFactoryProviderNamespace = "Microsoft.DataFactory"; + private const string InsightsProviderNamespace = "microsoft.insights"; + private const string KeyVaultProviderNamespace = "Microsoft.KeyVault"; + private const string NetworkProviderNamespace = "Microsoft.Network"; + private const string StorageProviderNamespace = "Microsoft.Storage"; + private const string WebAppProviderNamespace = "Microsoft.Web"; + + internal static IList RequiredProvidersForServiceManagement() + { + if (typeof(T).FullName.EndsWith("WebSiteManagementClient")) + { + return new[] { "website" }; + } + + if (typeof(T).FullName.EndsWith("ManagedCacheClient")) + { + return new[] { "cacheservice.Caching" }; + } + + if (typeof(T).FullName.EndsWith("SchedulerManagementClient")) + { + return new[] { "scheduler.jobcollections" }; + } + + return new string[0]; + } + + internal static IList RequiredProvidersForResourceManager() + { + if (typeof(T).FullName.EndsWith("ResourceManagementClient")) + { + return new[] { + CacheProviderNamespace, + ComputeProviderNamespace, + InsightsProviderNamespace, + KeyVaultProviderNamespace, + NetworkProviderNamespace, + StorageProviderNamespace, + WebAppProviderNamespace + }; + } + if (typeof(T).FullName.EndsWith("BatchManagementClient")) + { + return new[] { BatchProviderNamespace }; + } + + if (typeof(T).FullName.Equals("Microsoft.Azure.Management.Compute.ComputeManagementClient")) + { + return new[] { ComputeProviderNamespace }; + } + + if (typeof(T).FullName.Equals("Microsoft.Azure.Management.Dns.DnsManagementClient")) + { + return new[] { NetworkProviderNamespace }; + } + + if (typeof(T).FullName.EndsWith("DataPipelineManagementClient")) + { + return new[] { DataFactoryProviderNamespace }; + } + + if (typeof(T).FullName.Equals("Microsoft.Azure.Management.Network.NetworkResourceProviderClient")) + { + return new[] { NetworkProviderNamespace }; + } + + if (typeof(T).FullName.Equals("Microsoft.Azure.Management.Storage.StorageManagementClient")) + { + return new[] { StorageProviderNamespace }; + } + + return new string[0]; + } + } +} diff --git a/src/Common/Commands.Common/ServiceManagementTypes.cs b/src/Common/Commands.Common/ServiceManagementTypes.cs index 2eabbcf8cc04..421639e49e42 100644 --- a/src/Common/Commands.Common/ServiceManagementTypes.cs +++ b/src/Common/Commands.Common/ServiceManagementTypes.cs @@ -14,7 +14,6 @@ //TODO: When transition to SM.NET is completed, rename the namespace to "Microsoft.WindowsAzure.ServiceManagement" -using Microsoft.WindowsAzure.Commands.Common.Properties; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -28,6 +27,7 @@ using System.ServiceModel.Web; using System.Text; using System.Xml; +using Microsoft.WindowsAzure.Commands.Common.Properties; namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Model { diff --git a/src/Common/Commands.Common/SubscriptionCmdletBase.cs b/src/Common/Commands.Common/SubscriptionCmdletBase.cs index 53c8f04ca45b..5b9549e47ea3 100644 --- a/src/Common/Commands.Common/SubscriptionCmdletBase.cs +++ b/src/Common/Commands.Common/SubscriptionCmdletBase.cs @@ -22,7 +22,7 @@ namespace Microsoft.WindowsAzure.Commands.Utilities.Profile /// azure subscription, provides common support /// for the SubscriptionDataFile parameter. /// - public abstract class SubscriptionCmdletBase : AzurePSCmdlet + public abstract class SubscriptionCmdletBase : AzureSMCmdlet { private readonly bool _saveProfile; diff --git a/src/Common/Commands.Common/packages.config b/src/Common/Commands.Common/packages.config index abdfbbed145e..3ec82649e831 100644 --- a/src/Common/Commands.Common/packages.config +++ b/src/Common/Commands.Common/packages.config @@ -3,7 +3,7 @@ - + diff --git a/src/Common/Commands.Profile/Commands.Profile.csproj b/src/Common/Commands.Profile/Commands.Profile.csproj index f40f5ff69182..16be9cb12d53 100644 --- a/src/Common/Commands.Profile/Commands.Profile.csproj +++ b/src/Common/Commands.Profile/Commands.Profile.csproj @@ -19,7 +19,7 @@ true full false - bin\Debug\ + ..\..\Package\Debug\ServiceManagement\Azure\Services DEBUG;TRACE prompt 4 @@ -28,7 +28,7 @@ false - bin\Release\ + ..\..\Package\Release\ServiceManagement\Azure\Services TRACE;SIGN true pdbonly @@ -54,16 +54,12 @@ ..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll - ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.3-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll True ..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll - - False - ..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll - @@ -161,13 +157,9 @@ Always - - - - - {5ee72c53-1720-4309-b54b-5fb79703195f} - Commands.Common - + + Designer + @@ -175,6 +167,12 @@ PreserveNewest + + + {5ee72c53-1720-4309-b54b-5fb79703195f} + Commands.Common + + diff --git a/src/Common/Commands.Profile/Models/PsAzureSubscription.cs b/src/Common/Commands.Profile/Models/PsAzureSubscription.cs index 503df09b8533..aca02ac1a20e 100644 --- a/src/Common/Commands.Profile/Models/PsAzureSubscription.cs +++ b/src/Common/Commands.Profile/Models/PsAzureSubscription.cs @@ -21,29 +21,35 @@ namespace Microsoft.WindowsAzure.Commands.Profile.Models public class PSAzureSubscription { public PSAzureSubscription() {} - public PSAzureSubscription(AzureSubscription subscription, AzureProfile profile) + public PSAzureSubscription(AzureSubscription subscription, AzureSMProfile profile) { SubscriptionId = subscription.Id.ToString(); SubscriptionName = subscription.Name; Environment = subscription.Environment; - SupportedModes = subscription.GetProperty(AzureSubscription.Property.SupportedModes); DefaultAccount = subscription.Account; Accounts = profile.Accounts.Values.Where(a => a.HasSubscription(subscription.Id)).ToArray(); IsDefault = subscription.IsPropertySet(AzureSubscription.Property.Default); - IsCurrent = profile.Context.Subscription != null && profile.Context.Subscription.Id == subscription.Id; + IsCurrent = profile.DefaultContext != null && profile.DefaultContext.Subscription.Id == subscription.Id; CurrentStorageAccountName = subscription.GetProperty(AzureSubscription.Property.StorageAccount); TenantId = subscription.GetPropertyAsArray(AzureSubscription.Property.Tenants).FirstOrDefault(); } public string SubscriptionId { get; set; } + public string SubscriptionName { get; set; } + public string Environment { get; set; } - public string SupportedModes { get; set; } + public string DefaultAccount { get; set; } + public AzureAccount[] Accounts { get; set; } + public bool IsDefault { get; set; } + public bool IsCurrent { get; set; } + public string CurrentStorageAccountName { get; set; } + public string TenantId { get; set; } } } diff --git a/src/Common/Commands.Profile/Models/PsAzureSubscriptionExtended.cs b/src/Common/Commands.Profile/Models/PsAzureSubscriptionExtended.cs index dac56ab51dc5..3352e274c7b9 100644 --- a/src/Common/Commands.Profile/Models/PsAzureSubscriptionExtended.cs +++ b/src/Common/Commands.Profile/Models/PsAzureSubscriptionExtended.cs @@ -19,42 +19,69 @@ namespace Microsoft.WindowsAzure.Commands.Profile.Models { public class PSAzureSubscriptionExtended : PSAzureSubscription { - public PSAzureSubscriptionExtended() { } + public PSAzureSubscriptionExtended() + { + + } public PSAzureSubscriptionExtended(PSAzureSubscription subscription) { base.SubscriptionId = subscription.SubscriptionId; base.SubscriptionName = subscription.SubscriptionName; - base.SupportedModes = subscription.SupportedModes; base.Accounts = subscription.Accounts; base.IsDefault = subscription.IsDefault; base.IsCurrent = subscription.IsCurrent; base.TenantId = subscription.TenantId; } + public string ActiveDirectoryUserId { get; set; } + public AzureAccount Account { get; set; } + public X509Certificate2 Certificate { get; set; } + public string AccountAdminLiveEmailId { get; set; } + public int CurrentCoreCount { get; set; } + public int CurrentHostedServices { get; set; } + public int CurrentDnsServers { get; set; } + public int CurrentLocalNetworkSites { get; set; } + public int CurrentVirtualNetworkSites { get; set; } + public int CurrentStorageAccounts { get; set; } + public int MaxCoreCount { get; set; } + public int MaxDnsServers { get; set; } + public int MaxHostedServices { get; set; } + public int MaxLocalNetworkSites { get; set; } + public int MaxVirtualNetworkSites { get; set; } + public int MaxStorageAccounts { get; set; } + public string ServiceAdminLiveEmailId { get; set; } + public string SubscriptionRealName { get; set; } + public string SubscriptionStatus { get; set; } + public string OperationDescription { get; set; } + public string OperationId { get; set; } + public string OperationStatus { get; set; } + public string ServiceEndpoint { get; set; } + public string ResourceManagerEndpoint { get; set; } + public string GalleryEndpoint { get; set; } } -} +} \ No newline at end of file diff --git a/src/Common/Commands.Profile/Profile/ClearAzureProfile.cs b/src/Common/Commands.Profile/Profile/ClearAzureProfile.cs index f7e883de7414..b18f14738768 100644 --- a/src/Common/Commands.Profile/Profile/ClearAzureProfile.cs +++ b/src/Common/Commands.Profile/Profile/ClearAzureProfile.cs @@ -28,7 +28,7 @@ namespace Microsoft.WindowsAzure.Commands.Profile [Cmdlet(VerbsCommon.Clear, "AzureProfile"), OutputType(typeof(AzureEnvironment))] public class ClearAzureProfileCommand : SubscriptionCmdletBase { - [Parameter(Position = 1, HelpMessage = "Force deletion of AzureProfile without prompt")] + [Parameter(Position = 1, HelpMessage = "Force deletion of AzureSMProfile without prompt")] public SwitchParameter Force { get; set; } public ClearAzureProfileCommand() : base(true) { } diff --git a/src/Common/Commands.Profile/Profile/NewAzureProfile.cs b/src/Common/Commands.Profile/Profile/NewAzureProfile.cs index 9b3312b2979c..970c22394dc1 100644 --- a/src/Common/Commands.Profile/Profile/NewAzureProfile.cs +++ b/src/Common/Commands.Profile/Profile/NewAzureProfile.cs @@ -32,8 +32,8 @@ namespace Microsoft.WindowsAzure.Commands.Profile /// /// Creates new Microsoft Azure profile. /// - [Cmdlet(VerbsCommon.New, "AzureProfile"), OutputType(typeof(AzureProfile))] - public class NewAzureProfileCommand : AzurePSCmdlet + [Cmdlet(VerbsCommon.New, "AzureProfile"), OutputType(typeof(AzureSMProfile))] + public class NewAzureProfileCommand : AzureSMCmdlet { internal const string CertificateParameterSet = "Certificate"; internal const string CredentialsParameterSet = "Credentials"; @@ -100,18 +100,18 @@ public class NewAzureProfileCommand : AzurePSCmdlet public Hashtable Properties { get; set; } // do not use the Profile parameter for this cmdlet - private new AzureProfile Profile { get; set; } + private new AzureSMProfile Profile { get; set; } [PermissionSet(SecurityAction.Demand, Name = "FullTrust")] public override void ExecuteCmdlet() { - AzureProfile azureProfile; + AzureSMProfile AzureSMProfile; AzureProfileSettings settings; if (ParameterSetName == PropertyBagParameterSet) { - azureProfile = new AzureProfile(); + AzureSMProfile = new AzureSMProfile(); var actualParameterSet = ParseHashTableParameters(Properties, out settings); - InitializeAzureProfile(azureProfile, actualParameterSet, settings); + InitializeAzureProfile(AzureSMProfile, actualParameterSet, settings); } else if (ParameterSetName == FileParameterSet) { @@ -120,16 +120,16 @@ public override void ExecuteCmdlet() throw new ArgumentException(Resources.InvalidNewProfilePath); } - azureProfile = new AzureProfile(Path); + AzureSMProfile = new AzureSMProfile(Path); } else { - azureProfile = new AzureProfile(); + AzureSMProfile = new AzureSMProfile(); settings = AzureProfileSettings.Create(this); - InitializeAzureProfile(azureProfile, ParameterSetName, settings); + InitializeAzureProfile(AzureSMProfile, ParameterSetName, settings); } - WriteObject(azureProfile); + WriteObject(AzureSMProfile); } protected override void InitializeProfile() @@ -137,7 +137,7 @@ protected override void InitializeProfile() // do not initialize the current profile for this cmdlet } - private void InitializeAzureProfile(AzureProfile profile, string parameterSet, AzureProfileSettings settings) + private void InitializeAzureProfile(AzureSMProfile profile, string parameterSet, AzureProfileSettings settings) { var savedCache = AzureSession.TokenCache; AzureSession.TokenCache = DefaultMemoryTokenCache; diff --git a/src/Common/Commands.Profile/Profile/SelectAzureProfile.cs b/src/Common/Commands.Profile/Profile/SelectAzureProfile.cs index a6c302f564af..3954e936ab7b 100644 --- a/src/Common/Commands.Profile/Profile/SelectAzureProfile.cs +++ b/src/Common/Commands.Profile/Profile/SelectAzureProfile.cs @@ -32,14 +32,14 @@ namespace Microsoft.WindowsAzure.Commands.Profile /// /// Creates new Microsoft Azure profile. /// - [Cmdlet(VerbsCommon.Select, "AzureProfile"), OutputType(typeof(AzureProfile))] - public class SelectAzureProfileCommand : AzurePSCmdlet + [Cmdlet(VerbsCommon.Select, "AzureProfile"), OutputType(typeof(AzureSMProfile))] + public class SelectAzureProfileCommand : AzureSMCmdlet { internal const string NewProfileParameterSet = "NewProfile"; internal const string DefaultProfileParameterSet = "DefaultProfile"; [Parameter(ParameterSetName=NewProfileParameterSet, Mandatory=true, Position=0, ValueFromPipelineByPropertyName=true)] - public new AzureProfile Profile { get; set; } + public new AzureSMProfile Profile { get; set; } [Parameter(ParameterSetName=DefaultProfileParameterSet, Mandatory=true)] public SwitchParameter Default { get; set; } @@ -54,7 +54,7 @@ public override void ExecuteCmdlet() { if (ParameterSetName == DefaultProfileParameterSet) { - Profile = AzurePSCmdlet.InitializeDefaultProfile(); + Profile = AzureSMCmdlet.InitializeDefaultProfile(); } if (Profile == null) @@ -62,7 +62,7 @@ public override void ExecuteCmdlet() throw new ArgumentException(Resources.AzureProfileMustNotBeNull); } - AzurePSCmdlet.CurrentProfile = Profile; + AzureSMCmdlet.CurrentProfile = Profile; WriteObject(Profile); } } diff --git a/src/Common/Commands.Profile/Subscription/GetAzurePublishSettingsFile.cs b/src/Common/Commands.Profile/Subscription/GetAzurePublishSettingsFile.cs index 3cb69cddae84..92540f3a0340 100644 --- a/src/Common/Commands.Profile/Subscription/GetAzurePublishSettingsFile.cs +++ b/src/Common/Commands.Profile/Subscription/GetAzurePublishSettingsFile.cs @@ -48,7 +48,7 @@ public override void ExecuteCmdlet() { AzureEnvironment environment = ProfileClient.GetEnvironmentOrDefault(Environment); string url = environment.GetPublishSettingsFileUrlWithRealm(Realm); - GeneralUtilities.LaunchWebPage(url); + ProcessHelper.Start(url); if (PassThru) { diff --git a/src/Common/Commands.Profile/Subscription/GetAzureSubscription.cs b/src/Common/Commands.Profile/Subscription/GetAzureSubscription.cs index c63ef44e2931..f023249e8089 100644 --- a/src/Common/Commands.Profile/Subscription/GetAzureSubscription.cs +++ b/src/Common/Commands.Profile/Subscription/GetAzureSubscription.cs @@ -29,7 +29,7 @@ namespace Microsoft.WindowsAzure.Commands.Profile { /// /// Implementation of the get-azuresubscription cmdlet that works against - /// the AzureProfile layer. + /// the AzureSMProfile layer. /// [Cmdlet(VerbsCommon.Get, "AzureSubscription", DefaultParameterSetName = "ByName")] [OutputType(typeof(PSAzureSubscription))] @@ -66,9 +66,9 @@ public override void ExecuteCmdlet() { case "ByName": IEnumerable subscriptions = new AzureSubscription[0]; - if (Profile.Context != null && Profile.Context.Environment != null) + if (Profile.DefaultContext != null && Profile.DefaultContext.Environment != null) { - subscriptions = ProfileClient.RefreshSubscriptions(Profile.Context.Environment) + subscriptions = ProfileClient.RefreshSubscriptions(Profile.DefaultContext.Environment) .Where( s => SubscriptionName == null || @@ -113,7 +113,7 @@ public void GetCurrent() // since current is strictly in-memory and we want the real // current subscription. // - if (Profile.Context.Subscription == null) + if (Profile.DefaultContext.Subscription == null) { WriteError(new ErrorRecord( new InvalidOperationException(Resources.InvalidSelectedSubscription), @@ -122,7 +122,7 @@ public void GetCurrent() } else { - WriteSubscriptions(Profile.Context.Subscription); + WriteSubscriptions(Profile.DefaultContext.Subscription); } } diff --git a/src/Common/Commands.Profile/Subscription/ImportAzurePublishSettings.cs b/src/Common/Commands.Profile/Subscription/ImportAzurePublishSettings.cs index 8b47e0c1832b..ee1b2c4bf2a5 100644 --- a/src/Common/Commands.Profile/Subscription/ImportAzurePublishSettings.cs +++ b/src/Common/Commands.Profile/Subscription/ImportAzurePublishSettings.cs @@ -54,7 +54,7 @@ public override void ExecuteCmdlet() } AzureSubscription defaultSubscription = ProfileClient.Profile.DefaultSubscription; - Debug.Assert(Profile.Context != null); + Debug.Assert(Profile.DefaultContext != null); } private bool IsDirectory() diff --git a/src/Common/Commands.Profile/SwitchAzureMode.cs b/src/Common/Commands.Profile/SwitchAzureMode.cs index 099dfef5d1e2..8fd6a71d5211 100644 --- a/src/Common/Commands.Profile/SwitchAzureMode.cs +++ b/src/Common/Commands.Profile/SwitchAzureMode.cs @@ -24,7 +24,7 @@ namespace Microsoft.WindowsAzure.Commands.Profile /// Switches between ServiceManagement and ResourceManager modes. /// [Cmdlet(VerbsCommon.Switch, "AzureMode")] - public class SwitchAzureMode : AzurePSCmdlet + public class SwitchAzureMode : AzureSMCmdlet { [Parameter(Position = 0, Mandatory = true, HelpMessage = "Name of the mode to switch to. Valid values are AzureServiceManagement and AzureResourceManager")] [ValidateSet("AzureServiceManagement", "AzureResourceManager", IgnoreCase = false)] diff --git a/src/Common/Commands.Profile/packages.config b/src/Common/Commands.Profile/packages.config index 653d89f6ed0b..84297f357140 100644 --- a/src/Common/Commands.Profile/packages.config +++ b/src/Common/Commands.Profile/packages.config @@ -2,7 +2,7 @@ - + diff --git a/src/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs b/src/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs new file mode 100644 index 000000000000..96994ead919b --- /dev/null +++ b/src/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs @@ -0,0 +1,56 @@ +// ---------------------------------------------------------------------------------- +// +// 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.Management.Automation; +using Microsoft.Azure.Common.Authentication; +using Microsoft.Azure.Common.Authentication.Models; +using Microsoft.WindowsAzure.Commands.Utilities.Common; + +namespace Microsoft.Azure.Commands.ResourceManager.Common +{ + /// + /// Represents base class for Resource Manager cmdlets + /// + public abstract class AzureRMCmdlet : AzurePSCmdlet + { + /// + /// Static constructor for AzureRMCmdlet. + /// + static AzureRMCmdlet() + { + AzureSession.DataStore = new DiskDataStore(); + } + + /// + /// Gets or sets the global profile for ARM cmdlets. + /// + public static AzureRMProfile DefaultProfile { get; set; } + + /// + /// Gets the current default context. + /// + protected override AzureContext DefaultContext + { + get + { + if (DefaultProfile == null || DefaultProfile.DefaultContext == null) + { + throw new PSInvalidOperationException("Run Login-AzureRMAccount to login."); + } + + return DefaultProfile.DefaultContext; + } + } + } +} diff --git a/src/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj b/src/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj new file mode 100644 index 000000000000..ff1ad1950375 --- /dev/null +++ b/src/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj @@ -0,0 +1,180 @@ + + + + + Debug + AnyCPU + {3819D8A7-C62C-4C47-8DDD-0332D9CE1252} + Library + Properties + Microsoft.Azure.Commands.ResourceManager.Common + Microsoft.Azure.Commands.ResourceManager.Common + v4.5 + 512 + ..\..\ + true + /assemblyCompareMode:StrongNameIgnoringVersion + + + true + full + false + bin\Debug + DEBUG;TRACE + prompt + 4 + true + true + false + true + + + bin\Release + TRACE;SIGN + true + pdbonly + AnyCPU + bin\Release\Microsoft.Azure.Commands.ResourceManager.Common.dll.CodeAnalysisLog.xml + true + GlobalSuppressions.cs + prompt + MinimumRecommendedRules.ruleset + ;$(ProgramFiles)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\Rule Sets + ;$(ProgramFiles)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\Rules + true + MSSharedLibKey.snk + true + true + false + true + + + + False + ..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll + + + False + ..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll + + + False + ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + + + False + ..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll + + + False + ..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll + + + False + ..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll + + + False + ..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll + + + False + ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + + + False + ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + + + False + ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + + + False + ..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll + + + ..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll + True + + + ..\..\packages\Microsoft.Rest.ClientRuntime.1.2.0\lib\net45\Microsoft.Rest.ClientRuntime.dll + True + + + ..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.0.9.3\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll + True + + + + + + + + False + ..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll + + + False + ..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll + + + False + ..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll + + + + + + + + + + + + + + + + + + Common\AzurePSCmdlet.cs + + + Common\AzurePowerShell.cs + + + Common\CmdletExtensions.cs + + + Common\ConversionUtilities.cs + + + Common\DebugStreamTraceListener.cs + + + Common\GeneralUtilities.cs + + + Common\PowerShellUtilities.cs + + + Common\RecordingTracingInterceptor.cs + + + Common\SecureStringExtensions.cs + + + + + Designer + + + + + + + + + + \ No newline at end of file diff --git a/src/Common/Commands.ResourceManager.Common/MSSharedLibKey.snk b/src/Common/Commands.ResourceManager.Common/MSSharedLibKey.snk new file mode 100644 index 000000000000..695f1b38774e Binary files /dev/null and b/src/Common/Commands.ResourceManager.Common/MSSharedLibKey.snk differ diff --git a/src/Common/Commands.ResourceManager.Common/Properties/AssemblyInfo.cs b/src/Common/Commands.ResourceManager.Common/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..abfe416364fb --- /dev/null +++ b/src/Common/Commands.ResourceManager.Common/Properties/AssemblyInfo.cs @@ -0,0 +1,28 @@ +// ---------------------------------------------------------------------------------- +// +// 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.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Microsoft Azure PowerShell - Resource Manager Common Library")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Microsoft Azure PowerShell")] +[assembly: AssemblyCopyright("Copyright © Microsoft")] + +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] +[assembly: Guid("3819d8a7-c62c-4c47-8ddd-0332d9ce1252")] +[assembly: AssemblyVersion("1.0.0")] +[assembly: AssemblyFileVersion("1.0.0")] \ No newline at end of file diff --git a/src/Common/Commands.ResourceManager.Common/packages.config b/src/Common/Commands.ResourceManager.Common/packages.config new file mode 100644 index 000000000000..3ec82649e831 --- /dev/null +++ b/src/Common/Commands.ResourceManager.Common/packages.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/Common/Commands.ResourceManager.Profile.Test/Commands.ResourceManager.Profile.Test.csproj b/src/Common/Commands.ResourceManager.Profile.Test/Commands.ResourceManager.Profile.Test.csproj new file mode 100644 index 000000000000..a2007b8519c7 --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile.Test/Commands.ResourceManager.Profile.Test.csproj @@ -0,0 +1,216 @@ + + + + + + + Debug + AnyCPU + {152D78F0-A642-4D0E-B3A8-2FC64FFA9714} + Library + Properties + Microsoft.Azure.Commands.Profile.Test + Microsoft.Azure.Commands.Profile.Test + v4.5 + 512 + + ..\..\ + true + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 98e53b12 + + + true + full + false + bin\Debug + DEBUG;TRACE + prompt + 4 + true + true + false + + + bin\Release + TRACE;SIGN + true + pdbonly + AnyCPU + bin\Release\Microsoft.Azure.Commands.Profile.Test.dll.CodeAnalysisLog.xml + true + GlobalSuppressions.cs + prompt + MinimumRecommendedRules.ruleset + ;$(ProgramFiles)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\Rule Sets + ;$(ProgramFiles)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\Rules + true + MSSharedLibKey.snk + true + true + false + + + + ..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll + + + ..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll + + + False + ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + + + ..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll + + + ..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll + True + + + False + ..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll + + + ..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5715.36130-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll + True + + + False + ..\..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll + + + False + ..\..\packages\Microsoft.Data.OData.5.6.4\lib\net40\Microsoft.Data.OData.dll + + + False + ..\..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll + + + False + ..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll + + + False + ..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll + + + ..\..\packages\Microsoft.Rest.ClientRuntime.1.2.0\lib\net45\Microsoft.Rest.ClientRuntime.dll + True + + + ..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.0.9.3\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll + True + + + False + ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + + + False + ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + + + False + ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + + + + ..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.2.0.3.0\lib\net35-full\Microsoft.WindowsAzure.Configuration.dll + + + ..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll + + + ..\..\packages\Microsoft.WindowsAzure.Management.Compute.12.3.1\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll + + + ..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.1.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll + + + ..\..\packages\WindowsAzure.Storage.5.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll + + + False + ..\..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll + + + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + + + + + + + + + False + ..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll + + + False + ..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll + + + + + False + ..\..\packages\System.Spatial.5.6.4\lib\net40\System.Spatial.dll + + + + + + + + ..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll + True + + + ..\..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll + True + + + ..\..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll + True + + + + + + + + + + + + + {3819d8a7-c62c-4c47-8ddd-0332d9ce1252} + Commands.ResourceManager.Common + + + {142d7b0b-388a-4ceb-a228-7f6d423c5c2e} + Commands.ResourceManager.Profile + + + {c1bda476-a5cc-4394-914d-48b0ec31a710} + Commands.ScenarioTests.Common + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + \ No newline at end of file diff --git a/src/Common/Commands.ResourceManager.Profile.Test/MSSharedLibKey.snk b/src/Common/Commands.ResourceManager.Profile.Test/MSSharedLibKey.snk new file mode 100644 index 000000000000..695f1b38774e Binary files /dev/null and b/src/Common/Commands.ResourceManager.Profile.Test/MSSharedLibKey.snk differ diff --git a/src/Common/Commands.ResourceManager.Profile.Test/ProfileCmdletTests.cs b/src/Common/Commands.ResourceManager.Profile.Test/ProfileCmdletTests.cs new file mode 100644 index 000000000000..3a63befff5c2 --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile.Test/ProfileCmdletTests.cs @@ -0,0 +1,158 @@ +// ---------------------------------------------------------------------------------- +// +// 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 Microsoft.WindowsAzure.Commands.Utilities.Common; +using Microsoft.Azure.Commands.Profile; +using Microsoft.Azure.Commands.ResourceManager.Common; +using Microsoft.Azure.Common.Authentication; +using Microsoft.Azure.Common.Authentication.Models; +using Microsoft.WindowsAzure.Commands.Common.Test.Mocks; +using Microsoft.WindowsAzure.Commands.ScenarioTest; +using System.Linq; +using Xunit; +using System; +using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; + +namespace Microsoft.Azure.Commands.ResourceManager.Profile.Test +{ + public class ProfileCmdletTests : RMTestBase + { + private MemoryDataStore dataStore; + private MockCommandRuntime commandRuntimeMock; + + public ProfileCmdletTests() + { + dataStore = new MemoryDataStore(); + AzureSession.DataStore = dataStore; + commandRuntimeMock = new MockCommandRuntime(); + AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory(); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void SelectAzureProfileInMemory() + { + var profile = new AzureRMProfile(); + profile.Environments.Add("foo", AzureEnvironment.PublicEnvironments.Values.FirstOrDefault()); + SelectAzureProfileCommand cmdlt = new SelectAzureProfileCommand(); + // Setup + cmdlt.Profile = profile; + cmdlt.CommandRuntime = commandRuntimeMock; + + // Act + cmdlt.InvokeBeginProcessing(); + cmdlt.ExecuteCmdlet(); + cmdlt.InvokeEndProcessing(); + + // Verify + Assert.True(AzureRMCmdlet.DefaultProfile.Environments.ContainsKey("foo")); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void SelectAzureProfileNull() + { + SelectAzureProfileCommand cmdlt = new SelectAzureProfileCommand(); + // Setup + cmdlt.CommandRuntime = commandRuntimeMock; + + // Act + cmdlt.InvokeBeginProcessing(); + Assert.Throws(() => cmdlt.ExecuteCmdlet()); + cmdlt.InvokeEndProcessing(); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void SelectAzureProfileFromDisk() + { + var profile = new AzureRMProfile(); + profile.Environments.Add("foo", AzureEnvironment.PublicEnvironments.Values.FirstOrDefault()); + profile.Save("X:\\foo.json"); + SelectAzureProfileCommand cmdlt = new SelectAzureProfileCommand(); + // Setup + cmdlt.Path = "X:\\foo.json"; + cmdlt.CommandRuntime = commandRuntimeMock; + + // Act + cmdlt.InvokeBeginProcessing(); + cmdlt.ExecuteCmdlet(); + cmdlt.InvokeEndProcessing(); + + // Verify + Assert.True(AzureRMCmdlet.DefaultProfile.Environments.ContainsKey("foo")); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void SaveAzureProfileInMemory() + { + var profile = new AzureRMProfile(); + profile.Environments.Add("foo", AzureEnvironment.PublicEnvironments.Values.FirstOrDefault()); + SaveAzureProfileCommand cmdlt = new SaveAzureProfileCommand(); + // Setup + cmdlt.Profile = profile; + cmdlt.Path = "X:\\foo.json"; + cmdlt.CommandRuntime = commandRuntimeMock; + + // Act + cmdlt.InvokeBeginProcessing(); + cmdlt.ExecuteCmdlet(); + cmdlt.InvokeEndProcessing(); + + // Verify + Assert.True(AzureSession.DataStore.FileExists("X:\\foo.json")); + var profile2 = new AzureRMProfile("X:\\foo.json"); + Assert.True(profile2.Environments.ContainsKey("foo")); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void SaveAzureProfileNull() + { + SaveAzureProfileCommand cmdlt = new SaveAzureProfileCommand(); + // Setup + AzureRMCmdlet.DefaultProfile = null; + cmdlt.Path = "X:\\foo.json"; + cmdlt.CommandRuntime = commandRuntimeMock; + + // Act + Assert.Throws(() => cmdlt.ExecuteCmdlet()); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void SaveAzureProfileFromDefault() + { + var profile = new AzureRMProfile(); + profile.Environments.Add("foo", AzureEnvironment.PublicEnvironments.Values.FirstOrDefault()); + profile.DefaultContext = new AzureContext(new AzureSubscription(), new AzureAccount(), profile.Environments["foo"]); + AzureRMCmdlet.DefaultProfile = profile; + SaveAzureProfileCommand cmdlt = new SaveAzureProfileCommand(); + // Setup + cmdlt.Path = "X:\\foo.json"; + cmdlt.CommandRuntime = commandRuntimeMock; + + // Act + cmdlt.InvokeBeginProcessing(); + cmdlt.ExecuteCmdlet(); + cmdlt.InvokeEndProcessing(); + + // Verify + Assert.True(AzureSession.DataStore.FileExists("X:\\foo.json")); + var profile2 = new AzureRMProfile("X:\\foo.json"); + Assert.True(profile2.Environments.ContainsKey("foo")); + } + } +} diff --git a/src/Common/Commands.ResourceManager.Profile.Test/Properties/AssemblyInfo.cs b/src/Common/Commands.ResourceManager.Profile.Test/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..419035319ef3 --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +// ---------------------------------------------------------------------------------- +// +// 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.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Xunit; + +[assembly: AssemblyTitle("Microsoft Azure Powershell - Common ResourceManager Profile Test")] +[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)] +[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)] +[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)] + +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] +[assembly: AssemblyVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyVersion)] +[assembly: AssemblyFileVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyFileVersion)] \ No newline at end of file diff --git a/src/Common/Commands.ResourceManager.Profile.Test/packages.config b/src/Common/Commands.ResourceManager.Profile.Test/packages.config new file mode 100644 index 000000000000..06207a83cb8f --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile.Test/packages.config @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Common/Commands.ResourceManager.Profile/Commands.ResourceManager.Profile.csproj b/src/Common/Commands.ResourceManager.Profile/Commands.ResourceManager.Profile.csproj new file mode 100644 index 000000000000..c3b20d9827a2 --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile/Commands.ResourceManager.Profile.csproj @@ -0,0 +1,177 @@ + + + + Debug + AnyCPU + {142D7B0B-388A-4CEB-A228-7F6D423C5C2E} + Library + Properties + Microsoft.Azure.Commands.Profile + Microsoft.Azure.Commands.Profile + v4.5 + 512 + + ..\..\ + true + /assemblyCompareMode:StrongNameIgnoringVersion + + + true + full + false + ..\..\Package\Debug\ResourceManager\AzureResourceManager\Resources + DEBUG;TRACE + prompt + 4 + true + true + false + + + ..\..\Package\Release\ResourceManager\AzureResourceManager\Resources + TRACE;SIGN + true + pdbonly + AnyCPU + bin\Release\Commands.Profile.dll.CodeAnalysisLog.xml + true + GlobalSuppressions.cs + prompt + MinimumRecommendedRules.ruleset + ;$(ProgramFiles)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\Rule Sets + ;$(ProgramFiles)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\Rules + true + true + MSSharedLibKey.snk + true + false + + + + ..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll + + + ..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll + + + ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + True + + + ..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll + + + False + ..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll + + + + + ..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll + True + + + ..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll + True + + + ..\..\packages\Microsoft.Rest.ClientRuntime.1.2.0\lib\net45\Microsoft.Rest.ClientRuntime.dll + True + + + ..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.0.9.3\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll + True + + + False + ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + + + False + ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + + + False + ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + + + False + ..\lib\Microsoft.Web.Deployment.dll + + + False + ..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll + + + False + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + False + ..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll + + + False + ..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + Designer + Always + + + + + + + Designer + PreserveNewest + + + + + {3819d8a7-c62c-4c47-8ddd-0332d9ce1252} + Commands.ResourceManager.Common + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + + + + + \ No newline at end of file diff --git a/src/Common/Commands.ResourceManager.Profile/MSSharedLibKey.snk b/src/Common/Commands.ResourceManager.Profile/MSSharedLibKey.snk new file mode 100644 index 000000000000..695f1b38774e Binary files /dev/null and b/src/Common/Commands.ResourceManager.Profile/MSSharedLibKey.snk differ diff --git a/src/Common/Commands.ResourceManager.Profile/Microsoft.Azure.Commands.Profile.dll-Help.psd1 b/src/Common/Commands.ResourceManager.Profile/Microsoft.Azure.Commands.Profile.dll-Help.psd1 new file mode 100644 index 000000000000..acb022d51649 --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile/Microsoft.Azure.Commands.Profile.dll-Help.psd1 @@ -0,0 +1,86 @@ +# +# Module manifest for module 'Azure' +# +# Generated by: Microsoft Corporation +# +# Generated on: 5/23/2012 +# + +@{ + +# Version number of this module. +ModuleVersion = '0.8.8' + +# ID used to uniquely identify this module +GUID = 'D48CF693-4125-4D2D-8790-1514F44CE325' + +# Author of this module +Author = 'Microsoft Corporation' + +# Company or vendor of this module +CompanyName = 'Microsoft Corporation' + +# Copyright statement for this module +Copyright = '?Microsoft Corporation. All rights reserved.' + +# Description of the functionality provided by this module +Description = '' + +# Minimum version of the Windows PowerShell engine required by this module +PowerShellVersion = '3.0' + +# Name of the Windows PowerShell host required by this module +PowerShellHostName = '' + +# Minimum version of the Windows PowerShell host required by this module +PowerShellHostVersion = '' + +# Minimum version of the .NET Framework required by this module +DotNetFrameworkVersion = '4.0' + +# Minimum version of the common language runtime (CLR) required by this module +CLRVersion='4.0' + +# Processor architecture (None, X86, Amd64, IA64) required by this module +ProcessorArchitecture = 'None' + +# Modules that must be imported into the global environment prior to importing this module +RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module +ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in ModuleToProcess +NestedModules = '..\..\Package\Debug\ServiceManagement\Azure\Services\Microsoft.WindowsAzure.Commands.Profile.dll' + +# Functions to export from this module +FunctionsToExport = '*' + +# Cmdlets to export from this module +CmdletsToExport = '*' + +# Variables to export from this module +VariablesToExport = '*' + +# Aliases to export from this module +AliasesToExport = @() + +# List of all modules packaged with this module +ModuleList = @() + +# List of all files packaged with this module +FileList = @() + +# Private data to pass to the module specified in ModuleToProcess +PrivateData = '' + +} diff --git a/src/Common/Commands.ResourceManager.Profile/Microsoft.Azure.Commands.Profile.dll-Help.xml b/src/Common/Commands.ResourceManager.Profile/Microsoft.Azure.Commands.Profile.dll-Help.xml new file mode 100644 index 000000000000..e4d520115e03 --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile/Microsoft.Azure.Commands.Profile.dll-Help.xml @@ -0,0 +1,4907 @@ + + + + + Add-AzureAccount + + Adds the Azure account to Windows PowerShell + + + + + Add + AzureAccount + + + + The Add-AzureAccount cmdlet makes your Azure account and its subscriptions available in Windows PowerShell. It's like logging into your Azure account in Windows PowerShell. To log out of the account, use the Remove-AzureAccount cmdlet. + Add-AzureAccount downloads information about your Azure account and saves it in a subscription data file in your roaming user profile. It also gets an access token that allows Windows PowerShell to access your Azure account on your behalf. When the command completes, you can manage your Azure account in Windows PowerShell. + There are two different ways to make your Azure account available to Windows PowerShell. You can use the Add-AzureAccount cmdlet, which uses Azure Active Directory (Azure AD) authentication access tokens, or Import-AzurePublishSettingsFile, which uses a management certificate. For guidance on which method to use, see "How to: Connect to your subscription" (http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/#Connect). + When you run Add-AzureAccount, it displays an interactive window that prompts you to sign into your Azure account. This sign-in is valid until the access token expires. When it expires, cmdlets that require access to your account prompt you to run Add-AzureAccount again. + If you have a Microsoft Organizational account, you can use the -Credential parameter to add the subscriptions associated with your account to Windows PowerShell without an interactive dialog. + When specifying -ServicePrincipal switch a -Credential parameter is used to authenticate a Service Principal. + + + + Add-AzureAccount + + Environment + + Specifies an Azure environment for the user account. This parameter is optional. The default is the AzureCloud environment.An Azure environment an independent deployment of Microsoft Azure, such as AzureCloud for global Azure and AzureChinaCloud for Azure operated by 21Vianet in China. You can also create on-premises Azure environments by using Azure Pack and the WAPack cmdlets. For more information, see Azure Pack.To get the available Azure environments, use the Get-AzureEnvironment cmdlet. To add an environment, use the Add-AzureEnvironment cmdlet. + + String + + + Credential + + The username and password account credentials used to authenticate with Azure Active Directory. The credentials must be for a Microsoft Organizational account or Service Principal, not a Microsoft account. + + PSCredential + + + Profile + + The Profile to add accounts and subscriptions to. If not specified, adds accounts and subscriptions to the default (on disk) profile. + + AzureProfile + + + + Add-AzureAccount + + Environment + + Specifies an Azure environment for the user account. This parameter is optional. The default is the AzureCloud environment.An Azure environment an independent deployment of Microsoft Azure, such as AzureCloud for global Azure and AzureChinaCloud for Azure operated by 21Vianet in China. You can also create on-premises Azure environments by using Azure Pack and the WAPack cmdlets. For more information, see Azure Pack.To get the available Azure environments, use the Get-AzureEnvironment cmdlet. To add an environment, use the Add-AzureEnvironment cmdlet. + + String + + + Credential + + The username and password account credentials used to authenticate with Azure Active Directory. The credentials must be for a Microsoft Organizational account or Service Principal, not a Microsoft account. + + PSCredential + + + ServicePrincipal + + Specifies that your are logging in as a service principal. You must give a Credentials parameter for this case, with the service principal ID as the user name and the service principal key as the password. + + SwitchParameter + + + Tenant + + Used when logging in as a service principal. Specifies the AAD tenant the service principal is defined in. This can be either the tenant's domain name or id. + + String + + + Profile + + The Profile to add accounts and subscriptions to. If not specified, adds accounts and subscriptions to the default (on disk) profile. + + AzureProfile + + + + + + Environment + + Specifies an Azure environment for the user account. This parameter is optional. The default is the AzureCloud environment.An Azure environment an independent deployment of Microsoft Azure, such as AzureCloud for global Azure and AzureChinaCloud for Azure operated by 21Vianet in China. You can also create on-premises Azure environments by using Azure Pack and the WAPack cmdlets. For more information, see Azure Pack.To get the available Azure environments, use the Get-AzureEnvironment cmdlet. To add an environment, use the Add-AzureEnvironment cmdlet. + + String + + String + + + + + + Credential + + The username and password account credentials used to authenticate with Azure Active Directory. The credentials must be for a Microsoft Organizational account or Service Principal, not a Microsoft account. + + PSCredential + + PSCredential + + + + + + Profile + + The Profile to add accounts and subscriptions to. If not specified, adds accounts and subscriptions to the default (on disk) profile. + + AzureProfile + + AzureProfile + + + Default on-disk Profile + + + ServicePrincipal + + Specifies that your are logging in as a service principal. You must give a Credentials parameter for this case, with the service principal ID as the user name and the service principal key as the password. + + SwitchParameter + + SwitchParameter + + + + + + Tenant + + Used when logging in as a service principal. Specifies the AAD tenant the service principal is defined in. This can be either the tenant's domain name or id. + + String + + String + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + None + + + + + + + + + + + + + + + Add-AzureAccount (and the Azure AD authentication method) takes precedence over Import-AzurePublishSettings (and the management certificate method). If you use Add-AzureAccount even once on your account, the Azure AD authentication method is used and the management certificate is ignored. To remove the Azure AD token and restore the management certificate method, use the Remove-AzureAccount cmdlet. For more information, type: Get-Help Remove-AzureAccount. + + + + + -------------------------- Example 1: Add an account -------------------------- + + PS C:\> + + PS C:\>Add-AzureAccount + + This command adds an Azure account to Windows PowerShell. When you run the command, a windows pops up to request the user name and password of the account. + + + + + + + + + + + + + + -------------------------- Example 2: Use an alternate subscription data file -------------------------- + + PS C:\> + + PS C:\>Add-AzureAccount -SubscriptionDataFile C:\Testing\SDF.xml + + This command uses the SubscriptionDataFile parameter to direct Add-AzureAccount to store the account data in the C:\Testing\SDF.xml file, instead of the default file. + + + + + + + + + + + + + + -------------------------- Example 3: Add a Microsoft Organizational account using Credential -------------------------- + + PS C:\> + + PS C:\>$credential = Get-Credential + PS C:\>Add-AzureAccount -Credential $credential + + This command uses the Credential parameter to provide AAD authentication information on the command line, rather than using the pop-up dialog for AAD authentication. + + + + + + + + + + + + + + -------------------------- Example 4: Add a Service Principal account using Credential and ServicePrincipal -------------------------- + + PS C:\> + + PS C:\>$credential = Get-Credential + PS C:\>Add-AzureAccount -Credential $credential -ServicePrincipal -Tenant "3EB32C56-E1E5-46A6-9410-F4A0572B3998" + + This command uses the Credential parameter to provide AAD authentication information of the Service Principal in the tenant 3EB32C56-E1E5-46A6-9410-F4A0572B3998. + + + + + + + + + + + + + + -------------------------- Example 5: Add an account in Azure China -------------------------- + + PS C:\> + + PS C:\>Add-AzureAccount -Environment AzureChinaCloud + + This command uses the Environment parameter to add an Azure China account to Windows PowerShell. When you run the command, a windows pops up to request the user name and password of the account. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397618 + + + Add-AzureEnvironment + + + + Get-AzureEnvironment + + + + Import-AzurePublishSettingsFile + + + + Get-AzureAccount + + + + Remove-AzureAccount + + + + + + + + Add-AzureEnvironment + + Creates an Azure environment + + + + + Add + AzureEnvironment + + + + The Add-AzureEnvironment cmdlet creates a new custom Azure account environment and saves it in your roaming user profile. The cmdlet returns an object that represents the new environment. When the command completes, you can use the environment in Windows PowerShell. + An Azure environment an independent deployment of Microsoft Azure, such as AzureCloud for global Azure and AzureChinaCloud for Azure operated by 21Vianet in China. You can also create on-premises Azure environments by using Azure Pack and the WAPack cmdlets. For more information, see Azure Pack (http://www.microsoft.com/en-us/server-cloud/products/windows-azure-pack/default.aspx). + Only the Name parameter of this cmdlet is mandatory. If you omit a parameter, its value is null ($null), and the service that uses that endpoint might not function properly. To add or change the value of an environment property, use the Set-AzureEnvironment cmdlet. + NOTE: Changing your environment can cause your account to fail. Typically, environments are added only for testing or troubleshooting. + + + + Add-AzureEnvironment + + Name + + Specifies a name for the environment. This parameter is required. Do not use the names of the default environments, AzureCloud and AzureChinaCloud. + + String + + + PublishSettingsFileUrl + + Specifies the URL of the publish settings files for your account. An Azure publish settings file is an XML file that contains information about your account and a management certificate that allows Windows PowerShell to sign into your Azure account on your behalf. + + String + + + ServiceEndpoint + + Specifies the URL of the Azure service endpoint. The Azure service endpoint determines whether your application is managed by the global Azure platform, Azure operated by 21Vianet in China, or a private Azure installation. + + String + + + ManagementPortalUrl + + Specifies the URL of the Azure Management Portal in the new environment. + + String + + + StorageEndpoint + + Specifies the default endpoint of storage services in the new environment. + + String + + + ActiveDirectoryEndpoint + + Specifies the endpoint for Azure Active Directory authentication in the new environment. + + String + + + ResourceManagerEndpoint + + Specifies the endpoint for Azure Resource Manager data, including data about resource groups associated with the account. For more information about Azure Resource Manager, see Azure Resource Manager Cmdlets (http://go.microsoft.com/fwlink/?LinkID=394765) and Using Windows PowerShell with Resource Manager (http://go.microsoft.com/fwlink/?LinkID=394767). + + String + + + GalleryEndpoint + + Specifies the endpoint for the Azure Resource Manager gallery, which stores resource group gallery templates. For more information about Azure resource groups and gallery templates, see the help topic for Get-AzureResourceGroupGalleryTemplate. + + String + + + ActiveDirectoryServiceEndpointResourceId + + Specifies the resource ID of a management API whose access is managed by Azure Active Directory. + + String + + + GraphEndpoint + + Changes the endpoint for Azure Active Directory Graph API to the specified value. + + String + + + AzureKeyVaultDnsSuffix + + The DNS suffix for Azure KeyVaut; servers in this environment + + String + + + AzureKeyVaultServiceEndpointResourceId + + The identity of the KeyVault endpoint, used to acquire a token for authenticating with the KeyValue service. + + String + + + Profile + + The Profile to add the environment to to. If not specified, adds the environment to the default (on disk) profile. + + AzureProfile + + + + + + Name + + Specifies a name for the environment. This parameter is required. Do not use the names of the default environments, AzureCloud and AzureChinaCloud. + + String + + String + + + + + + PublishSettingsFileUrl + + Specifies the URL of the publish settings files for your account. An Azure publish settings file is an XML file that contains information about your account and a management certificate that allows Windows PowerShell to sign into your Azure account on your behalf. + + String + + String + + + + + + ServiceEndpoint + + Specifies the URL of the Azure service endpoint. The Azure service endpoint determines whether your application is managed by the global Azure platform, Azure operated by 21Vianet in China, or a private Azure installation. + + String + + String + + + + + + ManagementPortalUrl + + Specifies the URL of the Azure Management Portal in the new environment. + + String + + String + + + + + + StorageEndpoint + + Specifies the default endpoint of storage services in the new environment. + + String + + String + + + + + + ActiveDirectoryEndpoint + + Specifies the endpoint for Azure Active Directory authentication in the new environment. + + String + + String + + + + + + ResourceManagerEndpoint + + Specifies the endpoint for Azure Resource Manager data, including data about resource groups associated with the account. For more information about Azure Resource Manager, see Azure Resource Manager Cmdlets (http://go.microsoft.com/fwlink/?LinkID=394765) and Using Windows PowerShell with Resource Manager (http://go.microsoft.com/fwlink/?LinkID=394767). + + String + + String + + + + + + GalleryEndpoint + + Specifies the endpoint for the Azure Resource Manager gallery, which stores resource group gallery templates. For more information about Azure resource groups and gallery templates, see the help topic for Get-AzureResourceGroupGalleryTemplate. + + String + + String + + + + + + ActiveDirectoryServiceEndpointResourceId + + Specifies the resource ID of a management API whose access is managed by Azure Active Directory. + + String + + String + + + + + + GraphEndpoint + + Changes the endpoint for Azure Active Directory Graph API to the specified value. + + String + + String + + + + + + AzureKeyVaultDnsSuffix + + The DNS suffix for Azure KeyVaut; servers in this environment + + String + + String + + + + + + AzureKeyVaultServiceEndpointResourceId + + The identity of the KeyVault endpoint, used to acquire a token for authenticating with the KeyValue service. + + String + + String + + + + + + Profile + + The Profile to add the environment to to. If not specified, adds the environment to the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + Microsoft.WindowsAzure.Commands.Utilities.Common.WindowsAzureEnvironment + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Add an Azure environment -------------------------- + + PS C:\> + + PS C:\>Add-AzureEnvironment -Name ContosoEnv -PublishSettingsFileUrl https://contoso.com/fwlink/?LinkID=101 -ServiceEndpoint https://contoso.com/fwlink/?LinkID=102 + Name : ContosoEnv + + PublishSettingsFileUrl : https://contoso.com/fwlink/?LinkID=101 + + ServiceEndpoint : https://contoso.com/fwlink/?LinkID=102 + + ResourceManagerEndpoint : + + ManagementPortalUrl : + + ActiveDirectoryEndpoint : + + ActiveDirectoryCommonTenantId : + + StorageEndpointSuffix : + + StorageBlobEndpointFormat : + + StorageQueueEndpointFormat : + + StorageTableEndpointFormat : + + GalleryEndpoint : + + This command creates the ContosoEnv Azure environment. + + + + + + + + + + + + + + -------------------------- Example 2: Add an Azure environment with Parameters -------------------------- + + PS C:\> + + PS C:\>Add-AzureEnvironment -Name ContosoEnv -PublishSettingsFileUrl "https://contoso.com/fwlink/?LinkID=101" -ServiceEndpoint "https://contoso.com/fwlink/?LinkID=102" -ResourceManagerEndpoint "https://contoso.com/fwlink/?LinkID=103" -GraphEndpoint "https://contoso.com/fwlink/?LinkID=104" + + This command creates the ContosoEnv Azure environment with PublishSettingsFileUrl, ServiceEndpoint, ResourceManagerEndpoint, and GraphEndpoint specified. All other endpoints are ignored. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397619 + + + Get-AzureEnvironment + + + + Remove-AzureEnvironment + + + + Set-AzureEnvironment + + + + + + + + Clear-AzureProfile + + Clears an Azure profile + + + + + Clear + AzureProfile + + + + The Clear-AzureProfile cmdlet resets Azure profile to default values. All imported subscriptions and accounts are removed. + + + + Clear-AzureProfile + + Force + + Suppresses the confirmation prompt. By default, Clear-AzureProfile prompts you before clearing the profile. + + SwitchParameter + + + Profile + + The Profile to remove all accounts, certificates, and subscriptions from. If not specified, removes all accounts and subscriptions from the default (on disk) profile. + + AzureProfile + + + + + + Force + + Suppresses the confirmation prompt. By default, Clear-AzureProfile prompts you before clearing the profile. + + SwitchParameter + + SwitchParameter + + + + + + Profile + + The Profile to remove all accounts, certificates, and subscriptions from. If not specified, removes all accounts and subscriptions from the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Clear profile -------------------------- + + PS C:\> + + PS C:\>Clear-AzureProfile + + This command clears default user Azure profile. + + + + + + + + + + + + + + -------------------------- Example 2: Clear nondefault profile -------------------------- + + PS C:\> + + PS C:\>Clear-AzureProfile -SubscriptionDataFile c:\myprofile.json + + This command clears Azure profile stored in c:\myprofile.json file. + + + + + + + + + + + + + + + + Get-AzureSubscription + + + + Set-AzureSubscription + + + + Add-AzureAccount + + + + Remove-AzureAccount + + + + + + + + Get-AzureAccount + + Gets Azure accounts that are available to Azure PowerShell. + + + + + Get + AzureAccount + + + + This is the Description section + The Get-AzureAccount cmdlet gets the Azure accounts that are available to Windows PowerShell. To make your accounts available to Windows PowerShell, use the Add-AzureAccount or Import-PublishSettingsFile cmdlets. + + + + Get-AzureAccount + + Name + + Gets only the specified account. The default is all accounts that are available to Windows PowerShell. Enter the account name. The Name value is case-sensitive. Wildcards are not permitted. + + String + + + Profile + + The Profile to get accounts from. If not specified, gets the accounts from the default (on disk) profile. + + AzureProfile + + + + + + Name + + Gets only the specified account. The default is all accounts that are available to Windows PowerShell. Enter the account name. The Name value is case-sensitive. Wildcards are not permitted. + + String + + String + + + + + + Profile + + The Profile to get accounts from. If not specified, gets the accounts from the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Get all accounts -------------------------- + + PS C:\> + + PS C:\>Get-AzureAccount + Name ActiveDirectories + ---- ----------------- + contosoadmin@outlook.com {{ ActiveDirectoryTenantId = abcde5cd-bcc3-441a-bd86-e6a... + contosotest1@outlook.com {{ ActiveDirectoryTenantId = aaeabcde-386c-4466-bf70-794... + + This command gets all accounts associated with the specified user. + + + + + + + + + + + + + + -------------------------- Example 2: Get an account by name -------------------------- + + PS C:\> + + PS C:\>Get-AzureAccount -Name contosoadmin@outlook.com + Name ActiveDirectories + ---- ----------------- + contosoadmin@outlook.com {{ ActiveDirectoryTenantId = abcde5cd-bcc3-441a-bd86-e6a... + + This command gets the ContosoAdmin account. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397620 + + + Add-AzureAccount + + + + Get-AzurePublishSettingsFile + + + + Import-AzurePublishSettingsFile + + + + Remove-AzureAccount + + + + + + + + Get-AzureEnvironment + + Gets Azure environments + + + + + Get + AzureEnvironment + + + + This is the Description section + The Get-AzureEnvironment cmdlet gets the Azure environments that are available to Windows PowerShell.An Azure environment an independent deployment of Microsoft Azure, such as AzureCloud for global Azure and AzureChinaCloud for Azure operated by 21Vianet in China. You can also create on-premises Azure environments by using Azure Pack and the WAPack cmdlets. For more information, see Azure Pack (http://www.microsoft.com/en-us/server-cloud/products/windows-azure-pack/default.aspx).The Get-AzureEnvironment cmdlet gets environments from your subscription data file, not from Azure. If the subscription data file is outdated, run the Add-AzureAccount or Import-PublishSettingsFile cmdlet to refresh it. + + + + Get-AzureEnvironment + + Name + + Gets only the specified environment. Type the environment name. The parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + + Profile + + The Profile to get environments from. If not specified, gets environments from the default (on disk) profile. + + AzureProfile + + + + + + Name + + Gets only the specified environment. Type the environment name. The parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + String + + + + + + Profile + + The Profile to get environments from. If not specified, gets environments from the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Get all environments -------------------------- + + PS C:\> + + PS C:\>Get-AzureEnvironment + EnvironmentName ServiceEndpoint ResourceManagerEndpoint PublishSettingsFileUrl + --------------- --------------- ----------------------- ---------------------- + + AzureCloud https://management.core.wi... https://management.azure.com/ http://go.microsoft.com/fw... + AzureChinaCloud https://management.core.ch... https://not-supported-serv... http://go.microsoft.com/fw... + + This command gets all environments that are available to Windows PowerShell. + + + + + + + + + + + + + + -------------------------- Example 2: Get an environment by name -------------------------- + + PS C:\> + + PS C:\>Get-AzureEnvironment -Name AzureCloud + Name : AzureCloud + + PublishSettingsFileUrl : http://go.microsoft.com/fwlink/?LinkID=301775 + + ServiceEndpoint : https://management.core.windows.net/ + + ResourceManagerEndpoint : https://management.azure.com/ + + ManagementPortalUrl : http://go.microsoft.com/fwlink/?LinkId=254433 + + ActiveDirectoryEndpoint : https://login.windows.net/ + + ActiveDirectoryCommonTenantId : common + + StorageEndpointSuffix : core.windows.net + + StorageBlobEndpointFormat : {0}://{1}.blob.core.windows.net/ + + StorageQueueEndpointFormat : {0}://{1}.queue.core.windows.net/ + + StorageTableEndpointFormat : {0}://{1}.table.core.windows.net/ + + GalleryEndpoint : https://gallery.azure.com/ + + This example gets the AzureCloud environment. + + + + + + + + + + + + + + -------------------------- Example 3: Get all properties of all environments -------------------------- + + PS C:\> + + PS C:\>Get-AzureEnvironment | ForEach-Object {Get-AzureEnvironment -Name $_.EnvironmentName} + + This command gets all properties of all environments. + + + The command uses the Get-AzureEnvironment cmdlet to get all Azure environments for this account. Then, it uses the Foreach-Object cmdlet to run a Get-AzureEnvironment command with the Name parameter on each environment. The value of the Name parameter is the EnvironmentName property of each environment.Without parameters, Get-AzureEnvironment gets only selected properties of an environment. + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397621 + + + Add-AzureAccount + + + + Add-AzureEnvironment + + + + Get-AzurePublishSettingsFile + + + + Import-AzurePublishSettingsFile + + + + Remove-AzureEnvironment + + + + Set-AzureEnvironment + + + + + + + + Get-AzurePublishSettingsFile + + Downloads the publish settings file for an Azure subscription. + + + + + Get + AzurePublishSettingsFile + + + + This is the Description section + The Get-AzurePublishSettingsFile cmdlet downloads a publish settings file for a subscription in your account. When the command completes, you can use the Import-PublishSettingsFile cmdlet to make the settings in the file available to Windows PowerShell.To make your Azure account available to Windows PowerShell, you can use a publish settings file or the Add-AzureAccount cmdlet. Publish settings files let you prepare the session in advance so you can run scripts and background jobs unattended. However, not all services support publish settings files. For example, the AzureResourceManager module does not support publish settings files.When you run Get-AzurePublishSettingsFile, it opens your default browser and prompts you to sign into your Azure account, select a subscription, and select a file system location for the publish settings file. Then, it downloads the publish settings file for your subscription into the file that you selected.A "publish settings file" is an XML file with a .publishsettings file name extension. The file contains an encoded certificate that provides management credentials for your Azure subscriptions.Security Note: Publish settings files contains credentials that are used to administer your Azure subscriptions and services. If malicious users access your publish settings file, they can edit, create, and delete your Azure services. As a security best practice, save the file to a location in your Downloads or Documents folder and then delete it after using Import-AzurePublishSettingsFile cmdlet to import the settings. + + + + Get-AzurePublishSettingsFile + + Environment + + Specifies an Azure environment.An Azure environment an independent deployment of Microsoft Azure, such as AzureCloud for global Azure and AzureChinaCloud for Azure operated by 21Vianet in China. You can also create on-premises Azure environments by using Azure Pack and the WAPack cmdlets. For more information, see Azure Pack (http://www.microsoft.com/en-us/server-cloud/products/windows-azure-pack/default.aspx). + + String + + + Realm + + Specifies the organization in an organizational ID. For example, if you sign into Azure as admin@contoso.com, the value of the Realm parameter is contoso.com. Use this parameter when you use an organizational ID to sign into the Azure portal. This parameter is not required when you use a Microsoft account, such as an outlook.com or live.com account. + + String + + + PassThru + + Returns True ($true) if the command succeeds and False ($false) if it fails. By default, this cmdlet does not return any output. The PassThru parameter is typically used in conditional statements in functions and scripts. + + SwitchParameter + + + Profile + + The Profile to retrieve the PublishSettings download endpoint from. If not specified, gets the PublishSettings download endpoint from the default (on disk) profile. + + AzureProfile + + + + + + Environment + + Specifies an Azure environment.An Azure environment an independent deployment of Microsoft Azure, such as AzureCloud for global Azure and AzureChinaCloud for Azure operated by 21Vianet in China. You can also create on-premises Azure environments by using Azure Pack and the WAPack cmdlets. For more information, see Azure Pack (http://www.microsoft.com/en-us/server-cloud/products/windows-azure-pack/default.aspx). + + String + + String + + + + + + Realm + + Specifies the organization in an organizational ID. For example, if you sign into Azure as admin@contoso.com, the value of the Realm parameter is contoso.com. Use this parameter when you use an organizational ID to sign into the Azure portal. This parameter is not required when you use a Microsoft account, such as an outlook.com or live.com account. + + String + + String + + + + + + PassThru + + Returns True ($true) if the command succeeds and False ($false) if it fails. By default, this cmdlet does not return any output. The PassThru parameter is typically used in conditional statements in functions and scripts. + + SwitchParameter + + SwitchParameter + + + + + + Profile + + The Profile to retrieve the PublishSettings download endpoint from. If not specified, gets the PublishSettings download endpoint from the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + None or System.Boolean + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Download a publish settings file -------------------------- + + PS C:\> + + PS C:\>Get-AzurePublishSettingsFile + + This command opens your default browser, connects to your Microsoft Azure account, and then downloads the .publishsettings file for your account. + + + + + + + + + + + + + + -------------------------- Example 2: Specify a realm -------------------------- + + PS C:\> + + PS C:\>Get-AzurePublishSettingsFile -Realm contoso.com -Passthru + + This command downloads the publish settings file for an account in the contoso.com domain. Use a command with the Realm parameter when you sign into Azure with an organizational account, instead of a Microsoft account. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397622 + + + Add-AzureAccount + + + + Import-AzurePublishSettingsFile + + + + + + + + Get-AzureSubscription + + Gets Azure subscriptions in Azure account. + + + + + Get + AzureSubscription + + + + This is the Description section + The Get-AzureSubscription cmdlet gets the subscriptions in your Azure account. You can use this cmdlet to get information about the subscription and to pipe the subscription to other cmdlets.Get-AzureSubscription requires access to your Azure accounts. Before you run Get-AzureSubscription, you must run the Add-AzureAccount cmdlet or the cmdlets that download and install a publish settings file (Get-AzurePublishSettingsFile, Import-AzurePublishSettingsFile. + + + + Get-AzureSubscription + + SubscriptionName + + Gets only the specified subscription. Enter the subscription name. The value is case-sensitive. Wildcard characters are not supported. By default, Get-AzureSubscription gets all subscriptions in your Azure accounts. + + String + + + ExtendedDetails + + Returns quota information for the subscription, in addition to the standard settings. + + SwitchParameter + + + Profile + + The Profile to get subscriptions from. If not specified, gets subscriptions from the default (on disk) profile. + + AzureProfile + + + + Get-AzureSubscription + + SubscriptionId + + Gets only the specified subscription. Enter the subscription Id. By default, Get-AzureSubscription gets all subscriptions in your Azure accounts. + + String + + + ExtendedDetails + + Returns quota information for the subscription, in addition to the standard settings. + + SwitchParameter + + + Profile + + The Profile to get subscriptions from. If not specified, gets subscriptions from the default (on disk) profile. + + AzureProfile + + + + Get-AzureSubscription + + Default + + Gets only the default subscription, that is, the subscription designated as "default." By default, Get-AzureSubscription gets all subscriptions in your Azure accounts. To designate a subscription as "default," use the Default parameter of the Select-AzureSubscription cmdlet. + + SwitchParameter + + + ExtendedDetails + + Returns quota information for the subscription, in addition to the standard settings. + + SwitchParameter + + + Profile + + The Profile to get subscriptions from. If not specified, gets subscriptions from the default (on disk) profile. + + AzureProfile + + + + Get-AzureSubscription + + Current + + Gets only the current subscription, that is, the subscription designated as "current." By default, Get-AzureSubscription gets all subscriptions in your Azure accounts. To designate a subscription as "current," use the Current parameter of the Select-AzureSubscription cmdlet. + + SwitchParameter + + + ExtendedDetails + + Returns quota information for the subscription, in addition to the standard settings. + + SwitchParameter + + + Profile + + The Profile to get subscriptions from. If not specified, gets subscriptions from the default (on disk) profile. + + AzureProfile + + + + + + SubscriptionName + + Gets only the specified subscription. Enter the subscription name. The value is case-sensitive. Wildcard characters are not supported. By default, Get-AzureSubscription gets all subscriptions in your Azure accounts. + + String + + String + + + + + + ExtendedDetails + + Returns quota information for the subscription, in addition to the standard settings. + + SwitchParameter + + SwitchParameter + + + + + + Profile + + The Profile to get subscriptions from. If not specified, gets subscriptions from the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + SubscriptionId + + Gets only the specified subscription. Enter the subscription Id. By default, Get-AzureSubscription gets all subscriptions in your Azure accounts. + + String + + String + + + + + + Default + + Gets only the default subscription, that is, the subscription designated as "default." By default, Get-AzureSubscription gets all subscriptions in your Azure accounts. To designate a subscription as "default," use the Default parameter of the Select-AzureSubscription cmdlet. + + SwitchParameter + + SwitchParameter + + + + + + Current + + Gets only the current subscription, that is, the subscription designated as "current." By default, Get-AzureSubscription gets all subscriptions in your Azure accounts. To designate a subscription as "current," use the Current parameter of the Select-AzureSubscription cmdlet. + + SwitchParameter + + SwitchParameter + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + Microsoft.WindowsAzure.Commands.Utilities.Common.AzureSubscription + + + + + + + + + + + + + + + Get-AzureSubscription gets data from the subscription data file that the Add-AzureAccount and Import-PublishSettingsFile cmdlets create. + + + + + -------------------------- Example 1: Get all subscriptions -------------------------- + + PS C:\> + + PS C:\> C:\PS>Get-AzureSubscription + + This command gets all subscriptions in the account. + + + + + + + + + + + + + + -------------------------- Example 2: Get a subscription by name -------------------------- + + PS C:\> + + PS C:\> C:\PS>Get-AzureSubscription –SubscriptionName "MyProdSubscription" + + This command gets only the "MyProdSubsciption" subscription. + + + + + + + + + + + + + + -------------------------- Example 3: Get the default subscription -------------------------- + + PS C:\> + + PS C:\> C:\PS>(Get-AzureSubscription -Default).SubscriptionName + + This command gets only the name of the default subscription. The command first gets the subscription and then uses the dot method to get the SubscriptionName property of the subscription. + + + + + + + + + + + + + + -------------------------- Example 4: Get selected subscription properties -------------------------- + + PS C:\> + + PS C:\> C:\PS>Get-AzureSubscription -Current | Format-List -Property SubscriptionName, Certificate + + This command returns a list with the name and certificate of the current subscription. It uses a Get-AzureSubscription command to get the current subscription. Then it pipes the subscription to a Format-List command that displays the selected properties in a list. + + + + + + + + + + + + + + -------------------------- Example 5: Use an alternate subscription data file -------------------------- + + PS C:\> + + PS C:\> C:\PS>Get-AzureSubscription -SubscriptionDataFile "C:\Temp\MySubscriptions.xml" + + This command gets subscriptions from the C:\Temp\MySubscriptions.xml subscription data file. Use the SubscriptionDataFile parameter if you specified an alternate subscription data file when you ran the Add-AzureAccount or Import-PublishSettingsFile cmdlets. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397623 + + + Add-AzureAccount + + + + Get-AzurePublishSettingsFile + + + + Import-AzurePublishSettingsFile + + + + Remove-AzureSubscription + + + + Set-AzureSubscription + + + + + + + + Import-AzurePublishSettingsFile + + Imports a publish settings file that lets you manage your Azure accounts in Windows PowerShell. + + + + + Import + AzurePublishSettingsFile + + + + This is the Description section + The Import-AzurePublishSettingsFile cmdlet imports a publish settings file (*.publishsettings) that contains information about your Azure accounts and saves a subscription data file on your computer. When the cmdlet completes, you can manage your Azure accounts in Windows PowerShell.Before running Import-AzurePublishSettingsFile, run Get-AzurePublishSettingsFile, which downloads and saves the publish settings file so you can import it.To make your Azure account available to Windows PowerShell, you can use a publish settings file or the Add-AzureAccount cmdlet. Publish settings files let you prepare the session in advance so you can run scripts and background jobs unattended. However, not all services support publish settings files. For example, the AzureResourceManager module does not support publish settings files.Security Note: Publish settings files contain a management certificate that is encoded, but not encrypted. If malicious users access your publish settings file, they might be able to edit, create, and delete your Azure services. As a security best practice, save the file to a location in your Downloads or Documents folder and then delete it after using Import-AzurePublishSettingsFile cmdlet to import the settings. + + + + Import-AzurePublishSettingsFile + + PublishSettingsFile + + Specifies the full path and filename of the publish settings file. This should match the file location that you entered when prompted by Get-AzurePublishSettingsFile. + + String + + + Environment + + Specifies the environment to use. This parameter is optional. If it is not provided, an environment will be chosen according to the endpoint in the publish settings file. + + String + + + Profile + + The Profile to add certificates and subscriptions to. If not specified, adds certificates and subscriptions to the default (on disk) profile. + + AzureProfile + + + + + + PublishSettingsFile + + Specifies the full path and filename of the publish settings file. This should match the file location that you entered when prompted by Get-AzurePublishSettingsFile. + + String + + String + + + + + + Environment + + Specifies the environment to use. This parameter is optional. If it is not provided, an environment will be chosen according to the endpoint in the publish settings file. + + String + + String + + + + + + Profile + + The Profile to add certificates and subscriptions to. If not specified, adds certificates and subscriptions to the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + None + + + + + + + + + + + + + + + A "publish settings file" is an XML file with a .publishsettings file name extension. The file contains an encoded certificate that provides management credentials for your Azure subscriptions. After you import this file, delete it to avoid security risks. + + + + + -------------------------- Example 1 -------------------------- + + PS C:\> + + PS C:\>Import-AzurePublishSettingsFile –PublishSettingsFile C:\Temp\MyAccount.publishsettings + + This command imports the "C:\Temp\MyAccount.publishsettings" file. + + + + + + + + + + + + + + -------------------------- Example 2 -------------------------- + + PS C:\> + + PS C:\>Import-AzurePublishSettingsFile –PublishSettingsFile C:\Temp\MyAccount.publishsettings –SubscriptionDataFile C:\Subs\Subscriptions.xml + + This command imports the "C:\Temp\MyAccountName-date-credentials.publishsettings" file and then saves the subscription data file in C:\Subs\Subscriptions.xml. + + + When you use the SubscriptionDataFile parameter to save your subscription data file in an alternate location, be sure to use the SubscriptionDataFile parameter of cmdlets that use subscription data file, such as Select-AzureSubscription and Remove-AzureAccount. + + + + + + + + + + + -------------------------- Example 3 -------------------------- + + PS C:\> + + PS C:\>Import-AzurePublishSettingsFile –PublishSettingsFile C:\Temp\MyAccount.publishsettings -Environment AzureChinaCloud + + This command imports the "C:\Temp\MyAccount.publishsettings" file and sets the Azure environment of all imported subscriptions to be AzureChinaCloud. This will overwrite the endpoints defined in the publish settings file. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397624 + + + How to Install and Configure Azure PowerShell + + + + Add-AzureAccount + + + + Get-AzurePublishSettingsFile + + + + + + + + New-AzureProfile + + Create a new credential profile for Microsoft Azure PowerShell cmdlets in the current PowerShell session. + + + + + New + AzureProfile + + + + Create a new credential profile for Microsoft Azure PowerShell cmdlets in the current PowerShell session. A credential Profile is a container for the environments, accounts, and subscriptions used to authenticate Microsoft Azure PowerShell cmdlets with Microsoft Azure endpoints. A profile created with tis command can be passed as a parameter to any Microsoft Azure PowerShell cmdlet and the cmdlet will use the passed in profile for authentication. You can also use Select-AzureProfile to select a profile for use by all cmdlets in the current PowerrShell session. This enables using different credential sets in different PowerShell sessions independently. + The cmdlet can initialize the created profile with a default subscription and the associated credentials. You can create a default subscription in the profile using a certificate, Azure ActiveDirectory Organization ID credewntials, Azure active directory Service Principal credentials, or an Azure Access Directory access token you acquire outside of PowerShell. + + + + New-AzureProfile + + Environment + + Sets the AzureEnvironment for the default subscription in the created AzureProfile. + + AzureEnvironment + + + SubscriptionId + + The Id of the default subscription for this profile. + + String + + + StorageAccount + + The default storage account for the default subscription in the created Profile. + + String + + + AccessToken + + The authorization token used to authenticate the default subscription in this Profile. + + String + + + AccountId + + The Account name associated with the AccessToken for the default subscription in this Profile. + + String + + + + New-AzureProfile + + Environment + + Sets the AzureEnvironment for the default subscription in the created AzureProfile. + + AzureEnvironment + + + SubscriptionId + + The Id of the default subscription for this profile. + + String + + + StorageAccount + + The default storage account for the default subscription in the created Profile. + + String + + + Credential + + Azure Organization ID credentials for authenticating the default subscription in this Profile. + + PSCredential + + + Tenant + + The Tenant Id for the default subscription in this Profile. + + String + + + ServicePrincipal + + The ServicePrincipal Credential used to authenticate the default subscription in this Profile. + + SwitchParameter + + + + New-AzureProfile + + Environment + + Sets the AzureEnvironment for the default subscription in the created AzureProfile. + + AzureEnvironment + + + SubscriptionId + + The Id of the default subscription for this profile. + + String + + + StorageAccount + + The default storage account for the default subscription in the created Profile. + + String + + + Credential + + Azure Organization ID credentials for authenticating the default subscription in this Profile. + + PSCredential + + + Tenant + + The Tenant Id for the default subscription in this Profile. + + String + + + + New-AzureProfile + + Environment + + Sets the AzureEnvironment for the default subscription in the created AzureProfile. + + AzureEnvironment + + + SubscriptionId + + The Id of the default subscription for this profile. + + String + + + StorageAccount + + The default storage account for the default subscription in the created Profile. + + String + + + Certificate + + The certificate used to authenticate the default subscription in this Profile. + + X509Certificate2 + + + + New-AzureProfile + + Path + + The fully-qualified path to an AzureProfile saved on disk. + + String + + + + New-AzureProfile + + Properties + + A hash table containing details about the default subscription for this profile. The Hash keys and values may include: + SubscriptionId + [string]: The subscription ID for the default subscription in this Profile. + Certificate + [X509Certificate2]: The certificate credentials for the default subscription in this Profile. + Username + [string]: The user name associated with the default subscription for this Profile. Used to acquire an Azure Active Directory User credential. + Password + [string]: The password associated with the default subscription for the Profile. Used to acquire an Azure Active Directory User or Service credential. + ServicePrincipal + [string]: The SPN associated with the default subscription for this Profile. Used to acquire an Azure Active Directory Service credential. + Tenant + [string]: The tenant associated with the default subscription for this Profile. Used to acquire an Azure Active Directory Service credential. + AccountId + [string]: The user name associated with the default subscription for this Profile. Used to create a credential when access token is also specified. + Token + [string]: The access token associated with the default subscription for this Profile. Used to create a credential when AccountId is also specified. + Environment + [string]: The name of the environment associated with the default subscription for this Profile. Defaults to 'AzureCloud' if not specified. + StorageAccount + [string]: The name of the default storage account associated with the default subscription for this Profile. + + Hashtable + + + + + + Environment + + Sets the AzureEnvironment for the default subscription in the created AzureProfile. + + AzureEnvironment + + AzureEnvironment + + + AzureCloud + + + SubscriptionId + + The Id of the default subscription for this profile. + + String + + String + + + + + + StorageAccount + + The default storage account for the default subscription in the created Profile. + + String + + String + + + + + + AccessToken + + The authorization token used to authenticate the default subscription in this Profile. + + String + + String + + + + + + AccountId + + The Account name associated with the AccessToken for the default subscription in this Profile. + + String + + String + + + + + + Credential + + Azure Organization ID credentials for authenticating the default subscription in this Profile. + + PSCredential + + PSCredential + + + + + + Tenant + + The Tenant Id for the default subscription in this Profile. + + String + + String + + + + + + ServicePrincipal + + The ServicePrincipal Credential used to authenticate the default subscription in this Profile. + + SwitchParameter + + SwitchParameter + + + + + + Certificate + + The certificate used to authenticate the default subscription in this Profile. + + X509Certificate2 + + X509Certificate2 + + + + + + Path + + The fully-qualified path to an AzureProfile saved on disk. + + String + + String + + + + + + Properties + + A hash table containing details about the default subscription for this profile. The Hash keys and values may include: + SubscriptionId + [string]: The subscription ID for the default subscription in this Profile. + Certificate + [X509Certificate2]: The certificate credentials for the default subscription in this Profile. + Username + [string]: The user name associated with the default subscription for this Profile. Used to acquire an Azure Active Directory User credential. + Password + [string]: The password associated with the default subscription for the Profile. Used to acquire an Azure Active Directory User or Service credential. + ServicePrincipal + [string]: The SPN associated with the default subscription for this Profile. Used to acquire an Azure Active Directory Service credential. + Tenant + [string]: The tenant associated with the default subscription for this Profile. Used to acquire an Azure Active Directory Service credential. + AccountId + [string]: The user name associated with the default subscription for this Profile. Used to create a credential when access token is also specified. + Token + [string]: The access token associated with the default subscription for this Profile. Used to create a credential when AccountId is also specified. + Environment + [string]: The name of the environment associated with the default subscription for this Profile. Defaults to 'AzureCloud' if not specified. + StorageAccount + [string]: The name of the default storage account associated with the default subscription for this Profile. + + Hashtable + + Hashtable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -------------------------- Create a new empty profile for the current session -------------------------- + + PS C:\> + + > Select-AzureProfile -Profile $(New-AzureProfile) +> Add-AzureAccount +> Get-AzureVM + + This creates a new empty profile and makes this profile active for the current Azure PowerShell session. Any commands executed in the current PowerShell window will use this in-memory Profile rather than the default profile on disk. + In the example above, the Add-AzureAccount cmdlet adds a subscription to the in-memory profile, and the Get-AzureVM command lists the VMs for this subscription. The added subscription is only visible in the current session, another PowerShell window could use a separate in-memory profile at the same time. When the PowerShell window is closed, the subscription and associated credentials are discarded. + + + + + + + + + + + + + + -------------------------- Create and use multiple profiles in a session -------------------------- + + PS C:\> + + > $profile1 = New-AzureProfile -SubscriptionId <subscription1> -Credential $(Get-Credential) +> $profile2 = New-AzureProfile -SubscriptionId <subscription2> -Credential $(Get-Credential) +> Get-AzureVM -Profile $profile1 +> Get-AzureVM -Profile $profile2 + + This example creates 2 profiles containing different default subscriptions. The VMs for each subscription are listed by passing in the profile on the command line. + Using this pattern, management actions can be easily executed using multiple subscriptions and mutliple sets of credentials within the same PowerShell session. + + + + + + + + + + + + + + + + Select-AzureProfile + + + + Clear-AzureProfile + + + + + + + + Remove-AzureAccount + + Deletes an Azure account from Windows PowerShell. + + + + + Remove + AzureAccount + + + + The Remove-AzureAccount cmdlet deletes an Azure account and its subscriptions from the subscription data file in your roaming user profile. It does not delete the account from Microsoft Azure, or change the actual account in any way. + Using this cmdlet is a lot like logging out of your Azure account. And, if you want to log into the account again, use the Add-AzureAccount or Import-AzurePublishSettingsFile to add the account to Windows PowerShell again. + You can also use Remove-AzureAccount cmdlet to change the way the Azure PowerShell cmdlets sign into your Azure account. If your account has both a management certificate from Import-AzurePublishSettingsFile and an access token from Add-AzureAccount, the Azure PowerShell cmdlets use only the access token; they ignore the management certificate. To use the management certificate, run Remove-AzureAccount. When Remove-AzureAccount finds both a management certificate and an access token, it deletes only the access token, instead of deleting the account. The management certificate is still there, so account is still available to Windows PowerShell. + + + + Remove-AzureAccount + + Name + + Specifies the name of the account to remove. The parameter value is case-sensitive. Wildcard characters are not supported. + + String + + + Force + + Suppresses the confirmation prompt. By default, Remove-AzureAccount prompts you before removing the account from Windows PowerShell. + + SwitchParameter + + + PassThru + + Returns True ($true) if the operation succeeded and False ($false) if it failed. By default, the cmdlet does not return any output. + + SwitchParameter + + + Profile + + The Profile to remove accounts from. If not specified, removes accounts from the default (on disk) profile. + + AzureProfile + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + + + + + Name + + Specifies the name of the account to remove. The parameter value is case-sensitive. Wildcard characters are not supported. + + String + + String + + + + + + Force + + Suppresses the confirmation prompt. By default, Remove-AzureAccount prompts you before removing the account from Windows PowerShell. + + SwitchParameter + + SwitchParameter + + + + + + PassThru + + Returns True ($true) if the operation succeeded and False ($false) if it failed. By default, the cmdlet does not return any output. + + SwitchParameter + + SwitchParameter + + + + + + Profile + + The Profile to remove accounts from. If not specified, removes accounts from the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + false + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + false + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + None or System.Boolean + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Remove an account -------------------------- + + PS C:\> + + PS C:\>Remove-AzureAccount -Name admin@contoso.com + + This command removes the admin@contoso.com from your subscription data file. When the command completes, the account is no longer available to Windows PowerShell. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397625 + + + Add-AzureAccount + + + + Get-AzureAccount + + + + + + + + Remove-AzureEnvironment + + Deletes an Azure environment from Windows PowerShell + + + + + Remove + AzureEnvironment + + + + This is the Description section + The Remove-AzureEnvironment cmdlet deletes an Azure environment from your roaming profile so Windows PowerShell can't find it. This cmdlet does not delete the environment from Microsoft Azure, or change the actual environment in any way.An Azure environment an independent deployment of Microsoft Azure, such as AzureCloud for global Azure and AzureChinaCloud for Azure operated by 21Vianet in China. You can also create on-premises Azure environments by using Azure Pack and the WAPack cmdlets. For more information, see Azure Pack (http://www.microsoft.com/en-us/server-cloud/products/windows-azure-pack/default.aspx). + + + + Remove-AzureEnvironment + + Name + + Specifies the name of the environment to remove. This parameter is required. This parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + + Force + + Suppresses the confirmation prompt. By default, Remove-AzureAccount prompts you before removing the account from Windows PowerShell. + + SwitchParameter + + + Profile + + The Profile to remove environments from. If not specified, removes environments from the default (on disk) profile. + + AzureProfile + + + + + + Name + + Specifies the name of the environment to remove. This parameter is required. This parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + String + + + + + + Force + + Suppresses the confirmation prompt. By default, Remove-AzureAccount prompts you before removing the account from Windows PowerShell. + + SwitchParameter + + SwitchParameter + + + + + + Profile + + The Profile to remove environments from. If not specified, removes environments from the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + PassThru + + Returns True ($true) if the command succeeds and False ($false) if it fails. By default, this cmdlet does not return any output. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + None or System.Boolean + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Delete an environment -------------------------- + + PS C:\> + + PS C:\>Remove-AzureEnvironment -Name ContosoEnv + + This command deletes the ContosoEnv environment from Windows PowerShell. + + + + + + + + + + + + + + -------------------------- Example 2: Delete multiple environments -------------------------- + + PS C:\> + + PS C:\>Get-AzureEnvironment | Where-Object EnvironmentName -like "Contoso*" | ForEach-Object {Remove-AzureEnvironment -Name $_.EnvironmentName } + + This command deletes environments whose names begin with "Contoso" from Windows PowerShell. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397626 + + + Add-AzureEnvironment + + + + Get-AzureEnvironment + + + + Set-AzureEnvironment + + + + + + + + Remove-AzureSubscription + + Deletes an Azure subscription from Windows PowerShell. + + + + + Remove + AzureSubscription + + + + The Remove-AzureSubscription cmdlet deletes an Azure subscription from your subscription data file so Windows PowerShell can't find it. This cmdlet does not delete the subscription from Microsoft Azure, or change the actual subscription in any way. + + + + Remove-AzureSubscription + + SubscriptionName + + Specifies the subscription name. This parameter is required. The parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + + Force + + Suppresses the confirmation prompt. By default, Remove-AzureSubscription prompts you before deleting the subscription. + + SwitchParameter + + + PassThru + + Returns True ($true) if the command succeeds and False ($false) if it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + + Profile + + The Profile to remove subscriptions from. If not specified, removes subscriptions from the default (on disk) profile. + + AzureProfile + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + + + Remove-AzureSubscription + + SubscriptionId + + Specifies the subscription Id. This parameter is required. + + String + + + Force + + Suppresses the confirmation prompt. By default, Remove-AzureSubscription prompts you before deleting the subscription. + + SwitchParameter + + + PassThru + + Returns True ($true) if the command succeeds and False ($false) if it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + + Profile + + The Profile to remove subscriptions from. If not specified, removes subscriptions from the default (on disk) profile. + + AzureProfile + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + + + + + SubscriptionName + + Specifies the subscription name. This parameter is required. The parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + String + + + + + + Force + + Suppresses the confirmation prompt. By default, Remove-AzureSubscription prompts you before deleting the subscription. + + SwitchParameter + + SwitchParameter + + + + + + PassThru + + Returns True ($true) if the command succeeds and False ($false) if it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + SwitchParameter + + + + + + Profile + + The Profile to remove subscriptions from. If not specified, removes subscriptions from the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + false + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + false + + + SubscriptionId + + Specifies the subscription Id. This parameter is required. + + String + + String + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + None or System.Boolean + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Delete a subscription -------------------------- + + PS C:\> + + PS C:\> C:\PS> Remove-AzureSubscription -SubscriptionName Test + + Confirm + Are you sure you want to perform this action? + [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): + + This command deletes the "Test" subscription from the default subscription data file. + + + + + + + + + + + + + + -------------------------- Example 2: Delete from an alternate subscription data file -------------------------- + + PS C:\> + + PS C:\> C:\PS> Remove-AzureSubscription -SubscriptionName Test -SubscriptionDataFile C:\Subs\MySubscriptions.xml -Force + + This command deletes the Test subscription from the MySubscriptions.xml subscription data file. The command uses the Force parameter to suppress the confirmation prompt. + + + + + + + + + + + + + + -------------------------- Example 3: Delete a subscription in a script -------------------------- + + PS C:\> + + PS C:\> C:\PS> ...if (Remove-AzureSubscription -SubscriptionName Test -PassThru) {...} + + This command uses the Remove-AzureSubscription command in an If statement. It uses the PassThru parameter, which returns a Boolean value, to determine whether the script block in the If statement is executed. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397627 + + + Get-AzureSubscription + + + + Select-AzureSubscription + + + + Set-AzureSubscription + + + + + + + + Select-AzureProfile + + Select the active profile for the current PowerShell session. + + + + + Select + AzureProfile + + + + Select the active profile for the current PowerShell session. A Profile is a container for subscriptions and associated credentials used to authenticate Microsoft Azure PowerShell cmdlets with Microsoft Azure services. + Any cmdlets executed in the current session will use the selected Profile until the window is closed or another Select-AzureProfile cmdlet is executed. + + + + Select-AzureProfile + + Profile + + The profile to select as the active Profile for the session. All cmdlets subsequently executed in the session will use the subscriptions contained in this Profile for authenticating with Microsoft Azure + + AzureProfile + + + + Select-AzureProfile + + Default + + Select the default on-disk profile as the active profile for the session. All subsequent cmdlets executed in the session will use the default on-disk Profile + + SwitchParameter + + + + + + Profile + + The profile to select as the active Profile for the session. All cmdlets subsequently executed in the session will use the subscriptions contained in this Profile for authenticating with Microsoft Azure + + AzureProfile + + AzureProfile + + + + + + Default + + Select the default on-disk profile as the active profile for the session. All subsequent cmdlets executed in the session will use the default on-disk Profile + + SwitchParameter + + SwitchParameter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Select-AzureSubscription + + Changes the current and default Azure subscriptions + + + + + Select + AzureSubscription + + + + The Select-AzureSubscription cmdlet sets and clears the current and default Azure subscriptions. + The "current subscription" is the subscription that is used by default in the current Windows PowerShell session. The "default subscription" is used by default in all Windows PowerShell sessions. The "current subscription" label lets you specify a different subscription to be used by default for the current session without changing the "default subscription" for all other sessions. + The "default" subscription designation is saved in your subscription data file. The session-specific "current" designation is not saved. + + + + Select-AzureSubscription + + SubscriptionName + + Specifies the subscription to change. Enter the subscription name. This parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + + Account + + Specifies optionally the account to use with the subscription. This parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + + Current + + Sets the "current" subscription. Use the SubscriptionName parameter to identify the subscription.The "current subscription" is the subscription that is used by default in the current Windows PowerShell session. + + SwitchParameter + + + PassThru + + Returns True ($true) when the operation succeeds and False ($false) when it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + + Profile + + The Profile to select the default subscription in. The default subscription in a profile is the subscription that is used when that profile is active in the current session. If not specified, selects the default subscription in the default (on disk) profile. + + AzureProfile + + + + Select-AzureSubscription + + SubscriptionName + + Specifies the subscription to change. Enter the subscription name. This parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + + Account + + Specifies optionally the account to use with the subscription. This parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + + Default + + Sets the "default" subscription. Use the SubscriptionName parameter to identify the subscription.The "default subscription" is the subscription that is used by default in the all Windows PowerShell sessions, unless a different subscription is set to "current". + + SwitchParameter + + + PassThru + + Returns True ($true) when the operation succeeds and False ($false) when it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + + Profile + + The Profile to select the default subscription in. The default subscription in a profile is the subscription that is used when that profile is active in the current session. If not specified, selects the default subscription in the default (on disk) profile. + + AzureProfile + + + + Select-AzureSubscription + + SubscriptionId + + Specifies the subscription Id to change. Enter the subscription Id. + + String + + + Account + + Specifies optionally the account to use with the subscription. This parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + + Current + + Sets the "current" subscription. Use the SubscriptionName parameter to identify the subscription.The "current subscription" is the subscription that is used by default in the current Windows PowerShell session. + + SwitchParameter + + + PassThru + + Returns True ($true) when the operation succeeds and False ($false) when it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + + Profile + + The Profile to select the default subscription in. The default subscription in a profile is the subscription that is used when that profile is active in the current session. If not specified, selects the default subscription in the default (on disk) profile. + + AzureProfile + + + + Select-AzureSubscription + + SubscriptionId + + Specifies the subscription Id to change. Enter the subscription Id. + + String + + + Account + + Specifies optionally the account to use with the subscription. This parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + + Default + + Sets the "default" subscription. Use the SubscriptionName parameter to identify the subscription.The "default subscription" is the subscription that is used by default in the all Windows PowerShell sessions, unless a different subscription is set to "current". + + SwitchParameter + + + PassThru + + Returns True ($true) when the operation succeeds and False ($false) when it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + + Profile + + The Profile to select the default subscription in. The default subscription in a profile is the subscription that is used when that profile is active in the current session. If not specified, selects the default subscription in the default (on disk) profile. + + AzureProfile + + + + Select-AzureSubscription + + Account + + Specifies optionally the account to use with the subscription. This parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + + NoCurrent + + Clears the "current" subscription setting. When no subscription is set to "current," the Azure PowerShell cmdlets use the default subscription. + + SwitchParameter + + + PassThru + + Returns True ($true) when the operation succeeds and False ($false) when it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + + Profile + + The Profile to select the default subscription in. The default subscription in a profile is the subscription that is used when that profile is active in the current session. If not specified, selects the default subscription in the default (on disk) profile. + + AzureProfile + + + + Select-AzureSubscription + + Account + + Specifies optionally the account to use with the subscription. This parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + + NoDefault + + Clears the "default" subscription setting. If there is no default subscription, the current subscription is used by default. When there is no current or default subscription, and you do not identify a subscription, commands that require a subscription fail. + + SwitchParameter + + + PassThru + + Returns True ($true) when the operation succeeds and False ($false) when it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + + Profile + + The Profile to select the default subscription in. The default subscription in a profile is the subscription that is used when that profile is active in the current session. If not specified, selects the default subscription in the default (on disk) profile. + + AzureProfile + + + + + + SubscriptionName + + Specifies the subscription to change. Enter the subscription name. This parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + String + + + + + + Account + + Specifies optionally the account to use with the subscription. This parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + String + + + + + + Current + + Sets the "current" subscription. Use the SubscriptionName parameter to identify the subscription.The "current subscription" is the subscription that is used by default in the current Windows PowerShell session. + + SwitchParameter + + SwitchParameter + + + + + + PassThru + + Returns True ($true) when the operation succeeds and False ($false) when it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + SwitchParameter + + + + + + Profile + + The Profile to select the default subscription in. The default subscription in a profile is the subscription that is used when that profile is active in the current session. If not specified, selects the default subscription in the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + Default + + Sets the "default" subscription. Use the SubscriptionName parameter to identify the subscription.The "default subscription" is the subscription that is used by default in the all Windows PowerShell sessions, unless a different subscription is set to "current". + + SwitchParameter + + SwitchParameter + + + + + + SubscriptionId + + Specifies the subscription Id to change. Enter the subscription Id. + + String + + String + + + + + + NoCurrent + + Clears the "current" subscription setting. When no subscription is set to "current," the Azure PowerShell cmdlets use the default subscription. + + SwitchParameter + + SwitchParameter + + + + + + NoDefault + + Clears the "default" subscription setting. If there is no default subscription, the current subscription is used by default. When there is no current or default subscription, and you do not identify a subscription, commands that require a subscription fail. + + SwitchParameter + + SwitchParameter + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + None or AzureSubscription if PassThru + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Set the current subscription -------------------------- + + PS C:\> + + PS C:\> C:\PS> Select-AzureSubscription -Current -SubscriptionName ContosoEngineering + + This command makes "ContosoEngineering" the current subscription. + + + + + + + + + + + + + + -------------------------- Example 2: Set the current subscription with account -------------------------- + + PS C:\> + + PS C:\> C:\PS> Select-AzureSubscription -Current -SubscriptionName ContosoEngineering -Account user@mail.contoso.com + + This command makes "ContosoEngineering" the current subscription and user@mail.contoso.com the current user. + + + + + + + + + + + + + + -------------------------- Example 3: Set the default description -------------------------- + + PS C:\> + + PS C:\> C:\PS> Select-AzureSubscription -Default -SubscriptionName ContosoFinance -SubscriptionDataFile "C:\subs\MySubscriptions.xml" + + This command changes the default subscription to "ContosoFinance." It saves the setting in the Subscriptions.xml subscription data file, instead of the default subscription data file. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397628 + + + Get-AzureSubscription + + + + Remove-AzureSubscription + + + + Set-AzureSubscription + + + + + + + + Set-AzureEnvironment + + Changes the properties of an Azure environment + + + + + Set + AzureEnvironment + + + + This is the Description section + The Set-AzureEnvironment cmdlet changes the properties of an Azure environment. It returns an object that represents the environment with its new property values. Use the Name parameter to identify the environment and the other parameters to change property values. You cannot use Set-AzureEnvironment to change the name of an Azure environment.An Azure environment an independent deployment of Microsoft Azure, such as AzureCloud for global Azure and AzureChinaCloud for Azure operated by 21Vianet in China. You can also create on-premises Azure environments by using Azure Pack and the WAPack cmdlets. For more information, see Azure Pack (http://www.microsoft.com/en-us/server-cloud/products/windows-azure-pack/default.aspx).NOTE: Do not change the properties of the AzureCloud or AzureChinaCloud environments. Use this cmdlet to change the values of private environments that you create. + + + + Set-AzureEnvironment + + Name + + Identifies the environment that is being changed. This parameter is required. The parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + + PublishSettingsFileUrl + + Changes the URL for publish settings files in the specified environment. An Azure publish settings file is an XML file that contains information about your account and a management certificate that allows Windows PowerShell to sign into your Azure account on your behalf. + + String + + + ServiceEndpoint + + Changes the URL of the Azure service endpoint in the specified environment. The Azure service endpoint determines whether your application is managed by the global Azure platform, Azure operated by 21Vianet in China, or a private Azure installation. + + String + + + ManagementPortalUrl + + Changes the URL of the Azure Management Portal to the specified value. + + String + + + StorageEndpoint + + Changes the default endpoint of storage services in the specified environment. + + String + + + ActiveDirectoryEndpoint + + Changes the endpoint for Azure Active Directory authentication to the specified value. + + String + + + ResourceManagerEndpoint + + Changes the endpoint for Azure Resource Manager data, including data about resource groups associated with the account. For more information about Azure Resource Manager, see Azure Resource Manager Cmdlets (http://go.microsoft.com/fwlink/?LinkID=394765) and Using Windows PowerShell with Resource Manager (http://go.microsoft.com/fwlink/?LinkID=394767). + + String + + + GalleryEndpoint + + Changes the endpoint for the Azure Resource Manager gallery to the specified value. The gallery endpoint is the location for resource group gallery templates. For more information about Azure resource groups and gallery templates, see the help topic for Get-AzureResourceGroupGalleryTemplate. + + String + + + ActiveDirectoryServiceEndpointResourceId + + Specifies the resource ID of a management API whose access is managed by Azure Active Directory. + + String + + + GraphEndpoint + + Changes the endpoint for Azure Active Directory Graph API to the specified value. + + String + + + AzureKeyVaultDnsSuffix + + The dns suffix used by KeyValut endpoints in the environment. + + String + + + AzureKeyVaultServiceEndpointResourceId + + The audience used when acquiring tokens for use with the KeyValut service in this environment. + + String + + + Profile + + The Profile to set environment details in. If not specified, sets environment details in the default (on disk) profile. + + AzureProfile + + + + + + Name + + Identifies the environment that is being changed. This parameter is required. The parameter value is case-sensitive. Wildcard characters are not permitted. + + String + + String + + + + + + PublishSettingsFileUrl + + Changes the URL for publish settings files in the specified environment. An Azure publish settings file is an XML file that contains information about your account and a management certificate that allows Windows PowerShell to sign into your Azure account on your behalf. + + String + + String + + + + + + ServiceEndpoint + + Changes the URL of the Azure service endpoint in the specified environment. The Azure service endpoint determines whether your application is managed by the global Azure platform, Azure operated by 21Vianet in China, or a private Azure installation. + + String + + String + + + + + + ManagementPortalUrl + + Changes the URL of the Azure Management Portal to the specified value. + + String + + String + + + + + + StorageEndpoint + + Changes the default endpoint of storage services in the specified environment. + + String + + String + + + + + + ActiveDirectoryEndpoint + + Changes the endpoint for Azure Active Directory authentication to the specified value. + + String + + String + + + + + + ResourceManagerEndpoint + + Changes the endpoint for Azure Resource Manager data, including data about resource groups associated with the account. For more information about Azure Resource Manager, see Azure Resource Manager Cmdlets (http://go.microsoft.com/fwlink/?LinkID=394765) and Using Windows PowerShell with Resource Manager (http://go.microsoft.com/fwlink/?LinkID=394767). + + String + + String + + + + + + GalleryEndpoint + + Changes the endpoint for the Azure Resource Manager gallery to the specified value. The gallery endpoint is the location for resource group gallery templates. For more information about Azure resource groups and gallery templates, see the help topic for Get-AzureResourceGroupGalleryTemplate. + + String + + String + + + + + + ActiveDirectoryServiceEndpointResourceId + + Specifies the resource ID of a management API whose access is managed by Azure Active Directory. + + String + + String + + + + + + GraphEndpoint + + Changes the endpoint for Azure Active Directory Graph API to the specified value. + + String + + String + + + + + + AzureKeyVaultDnsSuffix + + The dns suffix used by KeyValut endpoints in the environment. + + String + + String + + + + + + AzureKeyVaultServiceEndpointResourceId + + The audience used when acquiring tokens for use with the KeyValut service in this environment. + + String + + String + + + + + + Profile + + The Profile to set environment details in. If not specified, sets environment details in the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + Microsoft.WindowsAzure.Commands.Utilities.Common.WindowsAzureEnvironment + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Change environment properties -------------------------- + + PS C:\> + + PS C:\>Set-AzureEnvironment -Name ContosoEnv -PublishSettingsFileUrl "https://contoso.com" -StorageEndpoint "contoso.com" -GraphEndpoint "https://contoso.com/fwlink/?LinkID=104" + + This command changes the values of the PublishSettingsFileUrl, StorageEndpoint, and GraphEndpoint properties of the ContosoEnv environment. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397629 + + + Add-AzureEnvironment + + + + Get-AzureEnvironment + + + + Remove-AzureEnvironment + + + + + + + + Set-AzureSubscription + + Creates or changes an Azure subscription + + + + + Set + AzureSubscription + + + + The Set-AzureSubscription cmdlet establishes and changes the properties of an Azure subscription. You can use this cmdlet to create a new subscription or change the properties of an existing subscription. + To create a new subscription, select a unique name for the value of the SubscriptionName parameter. To change an existing subscription, use the SubscriptionName parameter to identify the subscription. + This cmdlet changes the data in the subscription data file that you create when you use the Add-AzureAccount or Import-AzurePublishSettingsFile cmdlet to add an Azure account to Windows PowerShell. + + + + Set-AzureSubscription + + SubscriptionName + + Specifies the subscription name. If an Azure subscription with this name does not exist, this parameter creates a new subscription with the specified name. If the subscription exists, this parameter identifies the subscription and uses the other property values to change it.To get the names of existing Azure subscriptions, use the Get-AzureSubscription cmdlet. + + String + + + SubscriptionId + + Specifies the ID of the subscription. To get the subscription ID of an existing Azure subscription, use the Get-AzureSubscription cmdlet. + + String + + + Certificate + + Specifies a management certificate for the subscription. Management certificates are X.509 certificates that are saved as .cer files and uploaded to the Azure Management Portal. The certificate, including its private key, must be installed on the local computer, either in the current user's personal certificate store, or the local machine’s personal certificate store. + + X509Certificate2 + + + ServiceEndpoint + + Sets or changes the custom service endpoint for the management service to the specified value.The service endpoint is the Azure management API endpoint in the Azure environment. You can create custom service endpoints and set a different service endpoint for each subscription. + + String + + + ResourceManagerEndpoint + + Sets or changes the endpoint for Azure Resource Manager data to the specified value.For more information about Azure Resource Manager, see Azure Resource Manager Cmdlets (http://go.microsoft.com/fwlink/?LinkID=394765) and Using Windows PowerShell with Resource Manager (http://go.microsoft.com/fwlink/?LinkID=394767). + + String + + + CurrentStorageAccountName + + Designates the specified storage account as the "current" storage account for the subscription. Enter the storage account name. The parameter value is case-sensitive. Wildcard characters are not permitted.This parameter does not create a storage account; it just associates the storage account with the subscription. To create a storage account, use the New-AzureStorageAccount cmdlet. + + String + + + Environment + + Specifies the environment name. + + String + + + PassThru + + Returns True ($true) if the operation succeeds and False ($false) if it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + + Profile + + The Profile to set subscription details in. If not specified, sets subscription details in the default (on disk) profile. + + AzureProfile + + + + Set-AzureSubscription + + SubscriptionName + + Specifies the subscription name. If an Azure subscription with this name does not exist, this parameter creates a new subscription with the specified name. If the subscription exists, this parameter identifies the subscription and uses the other property values to change it.To get the names of existing Azure subscriptions, use the Get-AzureSubscription cmdlet. + + String + + + Certificate + + Specifies a management certificate for the subscription. Management certificates are X.509 certificates that are saved as .cer files and uploaded to the Azure Management Portal. The certificate, including its private key, must be installed on the local computer, either in the current user's personal certificate store, or the local machine’s personal certificate store. + + X509Certificate2 + + + ServiceEndpoint + + Sets or changes the custom service endpoint for the management service to the specified value.The service endpoint is the Azure management API endpoint in the Azure environment. You can create custom service endpoints and set a different service endpoint for each subscription. + + String + + + ResourceManagerEndpoint + + Sets or changes the endpoint for Azure Resource Manager data to the specified value.For more information about Azure Resource Manager, see Azure Resource Manager Cmdlets (http://go.microsoft.com/fwlink/?LinkID=394765) and Using Windows PowerShell with Resource Manager (http://go.microsoft.com/fwlink/?LinkID=394767). + + String + + + CurrentStorageAccountName + + Designates the specified storage account as the "current" storage account for the subscription. Enter the storage account name. The parameter value is case-sensitive. Wildcard characters are not permitted.This parameter does not create a storage account; it just associates the storage account with the subscription. To create a storage account, use the New-AzureStorageAccount cmdlet. + + String + + + Environment + + Specifies the environment name. + + String + + + PassThru + + Returns True ($true) if the operation succeeds and False ($false) if it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + + Profile + + The Profile to set subscription details in. If not specified, sets subscription details in the default (on disk) profile. + + AzureProfile + + + + Set-AzureSubscription + + SubscriptionId + + Specifies the ID of the subscription. To get the subscription ID of an existing Azure subscription, use the Get-AzureSubscription cmdlet. + + String + + + Certificate + + Specifies a management certificate for the subscription. Management certificates are X.509 certificates that are saved as .cer files and uploaded to the Azure Management Portal. The certificate, including its private key, must be installed on the local computer, either in the current user's personal certificate store, or the local machine’s personal certificate store. + + X509Certificate2 + + + ServiceEndpoint + + Sets or changes the custom service endpoint for the management service to the specified value.The service endpoint is the Azure management API endpoint in the Azure environment. You can create custom service endpoints and set a different service endpoint for each subscription. + + String + + + ResourceManagerEndpoint + + Sets or changes the endpoint for Azure Resource Manager data to the specified value.For more information about Azure Resource Manager, see Azure Resource Manager Cmdlets (http://go.microsoft.com/fwlink/?LinkID=394765) and Using Windows PowerShell with Resource Manager (http://go.microsoft.com/fwlink/?LinkID=394767). + + String + + + CurrentStorageAccountName + + Designates the specified storage account as the "current" storage account for the subscription. Enter the storage account name. The parameter value is case-sensitive. Wildcard characters are not permitted.This parameter does not create a storage account; it just associates the storage account with the subscription. To create a storage account, use the New-AzureStorageAccount cmdlet. + + String + + + Environment + + Specifies the environment name. + + String + + + PassThru + + Returns True ($true) if the operation succeeds and False ($false) if it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + + Profile + + The Profile to set subscription details in. If not specified, sets subscription details in the default (on disk) profile. + + AzureProfile + + + + + + SubscriptionName + + Specifies the subscription name. If an Azure subscription with this name does not exist, this parameter creates a new subscription with the specified name. If the subscription exists, this parameter identifies the subscription and uses the other property values to change it.To get the names of existing Azure subscriptions, use the Get-AzureSubscription cmdlet. + + String + + String + + + + + + SubscriptionId + + Specifies the ID of the subscription. To get the subscription ID of an existing Azure subscription, use the Get-AzureSubscription cmdlet. + + String + + String + + + + + + Certificate + + Specifies a management certificate for the subscription. Management certificates are X.509 certificates that are saved as .cer files and uploaded to the Azure Management Portal. The certificate, including its private key, must be installed on the local computer, either in the current user's personal certificate store, or the local machine’s personal certificate store. + + X509Certificate2 + + X509Certificate2 + + + + + + ServiceEndpoint + + Sets or changes the custom service endpoint for the management service to the specified value.The service endpoint is the Azure management API endpoint in the Azure environment. You can create custom service endpoints and set a different service endpoint for each subscription. + + String + + String + + + + + + ResourceManagerEndpoint + + Sets or changes the endpoint for Azure Resource Manager data to the specified value.For more information about Azure Resource Manager, see Azure Resource Manager Cmdlets (http://go.microsoft.com/fwlink/?LinkID=394765) and Using Windows PowerShell with Resource Manager (http://go.microsoft.com/fwlink/?LinkID=394767). + + String + + String + + + + + + CurrentStorageAccountName + + Designates the specified storage account as the "current" storage account for the subscription. Enter the storage account name. The parameter value is case-sensitive. Wildcard characters are not permitted.This parameter does not create a storage account; it just associates the storage account with the subscription. To create a storage account, use the New-AzureStorageAccount cmdlet. + + String + + String + + + + + + Environment + + Specifies the environment name. + + String + + String + + + + + + PassThru + + Returns True ($true) if the operation succeeds and False ($false) if it fails. By default, this cmdlet does not return any output. + + SwitchParameter + + SwitchParameter + + + + + + Profile + + The Profile to set subscription details in. If not specified, sets subscription details in the default (on disk) profile. + + AzureProfile + + AzureProfile + + + + + + SubscriptionDataFile + + [Deprecated]: The SubscriptionDataFile parameter is deprecated. This parameter will be removed in a future release. See https://github.com/Azure/azure-powershell/wiki/Proposed-Design-Stateless-Azure-Profile for a description of the upcoming mechanism for providing alternate sources of subscription information. Specifies the path to a profile file. This parameter is optional. If it is not provided, default file in the user's profile is used. + + string + + string + + + + + + + + + None + + + + + + + + + + + + + None or System.Boolean + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Create a new subscription -------------------------- + + PS C:\> + + PS C:\>$thumbprint = <Certificate Thumbprint> + PS C:\>$myCert = Get-Item cert:\\CurrentUser\My\$thumbprint + PS C:\>Set-AzureSubscription -SubscriptionName ContosotTest -Certificate $myCert -SubscriptionID 12345 + + These commands create the ContosoTest subscription in the default subscription data file. The commands add a management certificate and subscription ID for the new subscription. + + + When you run the Set-AzureSubscription command, the cmdlet looks for a subscription with the name "ContosoTest". If it doesn't find one, it creates a new subscription with the specified values. + + + + + + + + + + + -------------------------- Example 2: Change an existing subscription -------------------------- + + PS C:\> + + PS C:\> C:\PS> $thumbprint = <Thumbprint-2> + C:\PS> $differentCert = Get-Item cert:\\CurrentUser\My\$thumbprint + C:\PS> Set-AzureSubscription –SubscriptionName ContosoEngineering -Certificate $differentCert + + These commands are very similar to the commands in Example 1. However, because the SubscriptionName parameter now identifies an existing subscription, Set-AzureSubscription uses the remaining parameters to change the values of the existing subscription rather than creating a new subscription + + + + + + + + + + + + + + -------------------------- Example 2: Change the service endpoint -------------------------- + + PS C:\> + + PS C:\> C:\PS> Set-AzureSubscription –SubscriptionName ContosoEngineering -ServiceEndpoint "https://management.core.contoso.com" + + This command adds or changes a custom service endpoint for the ContosoEngineering subscription. + + + + + + + + + + + + + + -------------------------- Example 3: Clear property values -------------------------- + + PS C:\> + + PS C:\> C:\PS> Set-AzureSubscription –SubscriptionName ContosoEngineering –Certificate $null -ResourceManagerEndpoint $null + + This command sets the values of the Certificate and ResourceManagerEndpoint properties to null ($null). This clears the values of those properties without changing other settings. + + + + + + + + + + + + + + -------------------------- Example 4: Use an alternate subscription data file -------------------------- + + PS C:\> + + PS C:\> C:\PS> Set-AzureSubscription -SubscriptionName ContosoFinance -SubscriptionDataFile = C:\Azure\SubscriptionData.xml - CurrentStorageAccount ContosoStorage01 + + This command changes the current storage account of the ContosoFinance subscription to ContosoStorage01. The command uses the SubscriptionDataFile parameter to change the data in the C:\Azure\SubscriptionData.xml subscription data file. By default, Set-AzureSubscription uses the default subscription data file in your roaming user profile. + + + + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=397630 + + + Add-AzureAccount + + + + Get-AzureSubscription + + + + Import-AzurePublishSettingsFile + + + + Remove-AzureSubscription + + + + Select-AzureSubscription + + + + + + + + Switch-AzureMode + + Switches between the Azure and Azure Resource Manager modules + + + + + Switch + AzureMode + + + + This is the Description section + The Switch-AzureMode cmdlet switches between the Azure and Azure Resource Manager (AzureResourceManager) modules. These modules are not designed to be used in the same session. To determine which module is in your current session, use the Get-Module cmdlet.NOTE: The AzureResourceManager module is currently in preview. It might not provide the same management capabilities as the Azure module. Beginning in version 0.8,0, the Azure PowerShell installation includes both Azure modules and Azure Profile, a module of commands common to both modules. When you use the Azure PowerShell cmdlets, the Azure and Azure Profile modules are imported into the session by default. To remove the Azure module from the session and import the Azure Resource Manager module, use Switch-AzureMode. And, to switch back to the Azure module, just use Switch-AzureMode again. The Azure module includes cmdlets that help you to manage your Azure account in the traditional way. The cmdlets get, create, change, and remove individual resources such as storage accounts, virtual machines, SQL databases, web sites, media services, and cloud services.The new Azure Resource Manager module lets you manage your resources in an entirely new way. Instead of creating individual resources and trying to use them together, begin by imagining the service you want to create, such as a web portal, a blog, a photo gallery, a commerce site, or a wiki. Select a resource group template, including one of dozens in the Azure template gallery, or create your own. Each template provides a model of a complex service, complete with the resources that you need to support the service. Then use the template to create a resource group and its resources, and deploy and manage the related resources as a unit.You can use Switch-AzureMode to switch between Azure modules as often as you like. To set an Azure module as the default for all sessions, use the Global parameter when switching between modes. + + + + Switch-AzureMode + + Name + + Switches to the specified module. To switch to the Azure Resource Manager module, type AzureResourceManager. To switch to the Azure module, type AzureServiceManagement. This parameter is required. + + String + + + Global + + Switches all Windows PowerShell session to the specified Azure module. Use this parameter to save your module selection for other sessions. This parameter is optional. By default, the switch affects only the current session.This parameter requires administrator permissions. To use this parameter, start Windows PowerShell with the "Run as administrator" option. + + SwitchParameter + + + Profile + + + + AzureProfile + + + + + + Name + + Switches to the specified module. To switch to the Azure Resource Manager module, type AzureResourceManager. To switch to the Azure module, type AzureServiceManagement. This parameter is required. + + String + + String + + + + + + Global + + Switches all Windows PowerShell session to the specified Azure module. Use this parameter to save your module selection for other sessions. This parameter is optional. By default, the switch affects only the current session.This parameter requires administrator permissions. To use this parameter, start Windows PowerShell with the "Run as administrator" option. + + SwitchParameter + + SwitchParameter + + + + + + Profile + + + + AzureProfile + + AzureProfile + + + + + + + + + None + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + -------------------------- Example 1: Switch to the Azure Resource Manager module -------------------------- + + PS C:\> + + PS C:\>Switch-AzureMode -Name AzureResourceManager + PS C:\>Switch-AzureMode -Name AzureServiceManagement + + This command shows you how to switch between modules. The first command uses the Switch-AzureMode cmdlet to switch to the Azure Resource Manager module. The second command uses the Switch-AzureMode cmdlet to switch back to the Azure module. + + + When you import either module, the AzureProfile module, which includes commands common to both modules, including Add-AzureAccount, Get-AzureSubscription, and Switch-AzureMode, is imported, too. + + + + + + + + + + + -------------------------- Example 2: Switch all sessions to the Azure Resource Manager module -------------------------- + + PS C:\> + + PS C:\>Switch-AzureMode -Name AzureResourceManager -Global + + This command uses the Global parameter of Switch-AzureMode to switch all Microsoft Azure PowerShell sessions to the Azure Resource Manager module. If you close this session and open an new one, the Azure Resource Manager module is imported by default. + + + The Global parameter requires administrator permissions. To run this command, start Windows PowerShell with the "Run as administrator" option. + + + + + + + + + + + + + Online Version: + http://go.microsoft.com/fwlink/?LinkID=394398 + + + Azure Resource Manager Cmdlets + + + + Azure Service Management Cmdlets + + + + Azure Profile Cmdlets + + + + + \ No newline at end of file diff --git a/src/Common/Commands.ResourceManager.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml b/src/Common/Commands.ResourceManager.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml new file mode 100644 index 000000000000..b34dcf874e8b --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml @@ -0,0 +1,48 @@ + + + + + Microsoft.Azure.Common.Authentication.Models.PSAzureAccount + + Microsoft.Azure.Common.Authentication.Models.PSAzureAccount + + + + + + 30 + + + + 10 + + + + + + + + + + + + + + Id + + + Type + + + Subscriptions + + + Tenants + + + + + + + + diff --git a/src/Common/Commands.ResourceManager.Profile/Profile/SaveAzureProfile.cs b/src/Common/Commands.ResourceManager.Profile/Profile/SaveAzureProfile.cs new file mode 100644 index 000000000000..603ddb6a6bdc --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile/Profile/SaveAzureProfile.cs @@ -0,0 +1,53 @@ +// ---------------------------------------------------------------------------------- +// +// 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 Microsoft.Azure.Commands.Profile.Properties; +using Microsoft.Azure.Commands.ResourceManager.Common; +using Microsoft.Azure.Common.Authentication.Models; +using System; +using System.Management.Automation; + +namespace Microsoft.Azure.Commands.Profile +{ + /// + /// Saves Microsoft Azure profile. + /// + [Cmdlet(VerbsData.Save, "AzureProfile"), OutputType(typeof(AzureRMProfile))] + public class SaveAzureProfileCommand : AzureRMCmdlet + { + [Parameter(Mandatory = false, Position = 0, ValueFromPipelineByPropertyName = true)] + public AzureRMProfile Profile { get; set; } + + [Parameter(Mandatory = true, Position = 1, ValueFromPipelineByPropertyName = true)] + public string Path { get; set; } + + protected override void ProcessRecord() + { + if (Profile != null) + { + Profile.Save(Path); + } + else + { + if (AzureRMCmdlet.DefaultProfile == null) + { + throw new ArgumentException(Resources.AzureProfileMustNotBeNull); + } + AzureRMCmdlet.DefaultProfile.Save(Path); + } + + WriteVerbose(string.Format("Profile saved to: {0}.", Path)); + } + } +} diff --git a/src/Common/Commands.ResourceManager.Profile/Profile/SelectAzureProfile.cs b/src/Common/Commands.ResourceManager.Profile/Profile/SelectAzureProfile.cs new file mode 100644 index 000000000000..7639f12ab319 --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile/Profile/SelectAzureProfile.cs @@ -0,0 +1,57 @@ +// ---------------------------------------------------------------------------------- +// +// 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 Microsoft.Azure.Commands.Profile.Properties; +using Microsoft.Azure.Commands.ResourceManager.Common; +using Microsoft.Azure.Common.Authentication.Models; +using System; +using System.Management.Automation; + +namespace Microsoft.Azure.Commands.Profile +{ + /// + /// Selects Microsoft Azure profile. + /// + [Cmdlet(VerbsCommon.Select, "AzureProfile"), OutputType(typeof(AzureRMProfile))] + public class SelectAzureProfileCommand : AzureRMCmdlet + { + internal const string InMemoryProfileParameterSet = "InMemoryProfile"; + internal const string ProfileFromDiskParameterSet = "ProfileFromDisk"; + + [Parameter(ParameterSetName = InMemoryProfileParameterSet, Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true)] + public AzureRMProfile Profile { get; set; } + + [Parameter(ParameterSetName = ProfileFromDiskParameterSet, Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true)] + public string Path { get; set; } + + protected override void ProcessRecord() + { + if (!string.IsNullOrEmpty(Path)) + { + AzureRMCmdlet.DefaultProfile = new AzureRMProfile(Path); + } + else + { + AzureRMCmdlet.DefaultProfile = Profile; + } + + if (AzureRMCmdlet.DefaultProfile == null) + { + throw new ArgumentException(Resources.AzureProfileMustNotBeNull); + } + + WriteObject(AzureRMCmdlet.DefaultProfile); + } + } +} diff --git a/src/Common/Commands.ResourceManager.Profile/Properties/AssemblyInfo.cs b/src/Common/Commands.ResourceManager.Profile/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..01731f9f8e05 --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile/Properties/AssemblyInfo.cs @@ -0,0 +1,58 @@ +// ---------------------------------------------------------------------------------- +// +// 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.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Microsoft Azure Powershell")] +[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)] +[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)] +[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("03519c3b-67ba-4972-8054-f3cc3279d603")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyVersion)] +[assembly: AssemblyFileVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyFileVersion)] +#if SIGN +[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.CloudService.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.SqlDatabase.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +#else +[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.Test")] +[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.Common.Test")] +[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.CloudService.Test")] +[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.SqlDatabase.Test")] +#endif +[assembly: CLSCompliant(false)] diff --git a/src/Common/Commands.ResourceManager.Profile/Properties/Resources.Designer.cs b/src/Common/Commands.ResourceManager.Profile/Properties/Resources.Designer.cs new file mode 100644 index 000000000000..dd79754a58a3 --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile/Properties/Resources.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.Azure.Commands.Profile.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Azure.Commands.Profile.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Selected profile must not be null.. + /// + internal static string AzureProfileMustNotBeNull { + get { + return ResourceManager.GetString("AzureProfileMustNotBeNull", resourceCulture); + } + } + } +} diff --git a/src/Common/Commands.ResourceManager.Profile/Properties/Resources.resx b/src/Common/Commands.ResourceManager.Profile/Properties/Resources.resx new file mode 100644 index 000000000000..c868836664ff --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile/Properties/Resources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Selected profile must not be null. + + \ No newline at end of file diff --git a/src/Common/Commands.ResourceManager.Profile/packages.config b/src/Common/Commands.ResourceManager.Profile/packages.config new file mode 100644 index 000000000000..84297f357140 --- /dev/null +++ b/src/Common/Commands.ResourceManager.Profile/packages.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj b/src/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj index 4d6f265b39e5..0ee6526bc492 100644 --- a/src/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj +++ b/src/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj @@ -1,6 +1,6 @@  - + Debug @@ -16,7 +16,7 @@ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ true - 49188b82 + fd20f8bd true @@ -48,20 +48,24 @@ False - ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.3-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + ..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll ..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll + + ..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll + True + False ..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll - ..\..\packages\Microsoft.Azure.Test.Framework.1.0.5687.28567-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll + ..\..\packages\Microsoft.Azure.Test.Framework.1.0.5715.36130-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll - ..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5687.28567-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll + ..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5715.36130-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll False @@ -161,11 +165,13 @@ - + ..\..\packages\xunit.1.9.2\lib\net20\xunit.dll + True - + ..\..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll + True @@ -574,7 +580,7 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + xxbbcczc' try { - $set = Set-AzureApiManagementPolicy -Context $context -Policy $tenantValid -PassThru + $set = Set-AzureRMApiManagementPolicy -Context $context -Policy $tenantValid -PassThru Assert-AreEqual $true $set - Get-AzureApiManagementPolicy -Context $context -SaveAs 'TenantPolicy.xml' -Force + Get-AzureRMApiManagementPolicy -Context $context -SaveAs 'TenantPolicy.xml' -Force $exists = [System.IO.File]::Exists('TenantPolicy.xml') $policy = gc 'TenantPolicy.xml' Assert-True {$policy -like '**'} } finally { - $removed = Remove-AzureApiManagementPolicy -Context $context -PassThru -Force + $removed = Remove-AzureRMApiManagementPolicy -Context $context -PassThru -Force Assert-AreEqual $true $removed - $policy = Get-AzureApiManagementPolicy -Context $context + $policy = Get-AzureRMApiManagementPolicy -Context $context Assert-Null $policy } # test product policy $productValid = '' - $product = Get-AzureApiManagementProduct -Context $context -Title 'Unlimited' | Select -First 1 + $product = Get-AzureRMApiManagementProduct -Context $context -Title 'Unlimited' | Select -First 1 try { - $set = Set-AzureApiManagementPolicy -Context $context -Policy $productValid -ProductId $product.ProductId -PassThru + $set = Set-AzureRMApiManagementPolicy -Context $context -Policy $productValid -ProductId $product.ProductId -PassThru Assert-AreEqual $true $set - Get-AzureApiManagementPolicy -Context $context -ProductId $product.ProductId -SaveAs 'ProductPolicy.xml' -Force + Get-AzureRMApiManagementPolicy -Context $context -ProductId $product.ProductId -SaveAs 'ProductPolicy.xml' -Force $exists = [System.IO.File]::Exists('ProductPolicy.xml') $policy = gc 'ProductPolicy.xml' Assert-True {$policy -like '**'} } finally { - $removed = Remove-AzureApiManagementPolicy -Context $context -ProductId $product.ProductId -PassThru -Force + $removed = Remove-AzureRMApiManagementPolicy -Context $context -ProductId $product.ProductId -PassThru -Force Assert-AreEqual $true $removed - $policy = Get-AzureApiManagementPolicy -Context $context -ProductId $product.ProductId + $policy = Get-AzureRMApiManagementPolicy -Context $context -ProductId $product.ProductId Assert-Null $policy try @@ -1047,23 +1047,23 @@ Param($resourceGroupName, $serviceName) # test api policy $apiValid = 'versionAcceptAccept-Charset' - $api = Get-AzureApiManagementApi -Context $context | Select -First 1 + $api = Get-AzureRMApiManagementApi -Context $context | Select -First 1 try { - $set = Set-AzureApiManagementPolicy -Context $context -Policy $apiValid -ApiId $api.ApiId -PassThru + $set = Set-AzureRMApiManagementPolicy -Context $context -Policy $apiValid -ApiId $api.ApiId -PassThru Assert-AreEqual $true $set - $policy = Get-AzureApiManagementPolicy -Context $context -ApiId $api.ApiId -SaveAs 'ApiPolicy.xml' + $policy = Get-AzureRMApiManagementPolicy -Context $context -ApiId $api.ApiId -SaveAs 'ApiPolicy.xml' $exists = [System.IO.File]::Exists('ApiPolicy.xml') $policy = gc 'ApiPolicy.xml' Assert-True {$policy -like '**'} } finally { - $removed = Remove-AzureApiManagementPolicy -Context $context -ApiId $api.ApiId -PassThru -Force + $removed = Remove-AzureRMApiManagementPolicy -Context $context -ApiId $api.ApiId -PassThru -Force Assert-AreEqual $true $removed - $policy = Get-AzureApiManagementPolicy -Context $context -ApiId $api.ApiId + $policy = Get-AzureRMApiManagementPolicy -Context $context -ApiId $api.ApiId Assert-Null $policy try @@ -1075,15 +1075,15 @@ Param($resourceGroupName, $serviceName) # test operation policy $operationValid = '' - $api = Get-AzureApiManagementApi -Context $context | Select -First 1 - $operation = Get-AzureApiManagementOperation -Context $context -ApiId $api.ApiId | Select -First 1 + $api = Get-AzureRMApiManagementApi -Context $context | Select -First 1 + $operation = Get-AzureRMApiManagementOperation -Context $context -ApiId $api.ApiId | Select -First 1 try { - $set = Set-AzureApiManagementPolicy -Context $context -Policy $operationValid -ApiId $api.ApiId ` + $set = Set-AzureRMApiManagementPolicy -Context $context -Policy $operationValid -ApiId $api.ApiId ` -OperationId $operation.OperationId -PassThru Assert-AreEqual $true $set - $policy = Get-AzureApiManagementPolicy -Context $context -ApiId $api.ApiId -OperationId $operation.OperationId ` + $policy = Get-AzureRMApiManagementPolicy -Context $context -ApiId $api.ApiId -OperationId $operation.OperationId ` -SaveAs 'OperationPolicy.xml' $exists = [System.IO.File]::Exists('OperationPolicy.xml') $policy = gc 'OperationPolicy.xml' @@ -1091,10 +1091,10 @@ Param($resourceGroupName, $serviceName) } finally { - $removed = Remove-AzureApiManagementPolicy -Context $context -ApiId $api.ApiId -OperationId $operation.OperationId -PassThru -Force + $removed = Remove-AzureRMApiManagementPolicy -Context $context -ApiId $api.ApiId -OperationId $operation.OperationId -PassThru -Force Assert-AreEqual $true $removed - $policy = Get-AzureApiManagementPolicy -Context $context -ApiId $api.ApiId -OperationId $operation.OperationId + $policy = Get-AzureRMApiManagementPolicy -Context $context -ApiId $api.ApiId -OperationId $operation.OperationId Assert-Null $policy try @@ -1113,10 +1113,10 @@ function Certificate-CrudTest { Param($resourceGroupName, $serviceName) - $context = New-AzureApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $serviceName + $context = New-AzureRMApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $serviceName # get all certificates - $certificates = Get-AzureApiManagementCertificate -Context $context + $certificates = Get-AzureRMApiManagementCertificate -Context $context Assert-AreEqual 0 $certificates.Count @@ -1129,28 +1129,28 @@ Param($resourceGroupName, $serviceName) try { # upload certificate - $cert = New-AzureApiManagementCertificate -Context $context -CertificateId $certId -PfxFilePath $certPath -PfxPassword $certPassword + $cert = New-AzureRMApiManagementCertificate -Context $context -CertificateId $certId -PfxFilePath $certPath -PfxPassword $certPassword Assert-AreEqual $certId $cert.CertificateId Assert-AreEqual $certThumbprint $cert.Thumbprint Assert-AreEqual $certSubject $cert.Subject # get certificate - $cert = Get-AzureApiManagementCertificate -Context $context -CertificateId $certId + $cert = Get-AzureRMApiManagementCertificate -Context $context -CertificateId $certId Assert-AreEqual $certId $cert.CertificateId Assert-AreEqual $certThumbprint $cert.Thumbprint Assert-AreEqual $certSubject $cert.Subject # update certificate - $cert = Set-AzureApiManagementCertificate -Context $context -CertificateId $certId -PfxFilePath $certPath -PfxPassword $certPassword -PassThru + $cert = Set-AzureRMApiManagementCertificate -Context $context -CertificateId $certId -PfxFilePath $certPath -PfxPassword $certPassword -PassThru Assert-AreEqual $certId $cert.CertificateId Assert-AreEqual $certThumbprint $cert.Thumbprint Assert-AreEqual $certSubject $cert.Subject # list certificates - $certificates = Get-AzureApiManagementCertificate -Context $context + $certificates = Get-AzureRMApiManagementCertificate -Context $context Assert-AreEqual 1 $certificates.Count Assert-AreEqual $certId $certificates[0].CertificateId @@ -1160,14 +1160,14 @@ Param($resourceGroupName, $serviceName) finally { # remove uploaded certificate - $removed = Remove-AzureApiManagementCertificate -Context $context -CertificateId $certId -Force -PassThru + $removed = Remove-AzureRMApiManagementCertificate -Context $context -CertificateId $certId -Force -PassThru Assert-True {$removed} $cert = $null try { # check it was removed - $cert = Get-AzureApiManagementCertificate -Context $context -CertificateId $certId + $cert = Get-AzureRMApiManagementCertificate -Context $context -CertificateId $certId } catch { @@ -1185,10 +1185,10 @@ function AuthorizationServer-CrudTest { Param($resourceGroupName, $serviceName) - $context = New-AzureApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $serviceName + $context = New-AzureRMApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $serviceName # get all authoriaztion servers - $servers = Get-AzureApiManagementAuthorizationServer -Context $context + $servers = Get-AzureRMApiManagementAuthorizationServer -Context $context Assert-AreEqual 0 $servers.Count @@ -1213,7 +1213,7 @@ Param($resourceGroupName, $serviceName) $supportState = $true $tokenBodyParameters = @{'tokenname'='tokenvalue'} - $server = New-AzureApiManagementAuthorizationServer -Context $context -ServerId $serverId -Name $name -Description $description ` + $server = New-AzureRMApiManagementAuthorizationServer -Context $context -ServerId $serverId -Name $name -Description $description ` -ClientRegistrationPageUrl $clientRegistrationEndpoint -AuthorizationEndpointUrl $authorizationEndpoint ` -TokenEndpointUrl $tokenEndpoint -ClientId $clientId -ClientSecret $clientSecret -AuthorizationRequestMethods $authorizationMethods ` -GrantTypes $grantTypes -ClientAuthenticationMethods $clientAuthenticationMethods -TokenBodyParameters $tokenBodyParameters ` @@ -1246,7 +1246,7 @@ Param($resourceGroupName, $serviceName) Assert-AreEqual $supportState $server.SupportState Assert-AreEqual $tokenBodyParameters.Count $server.TokenBodyParameters.Count - $server = Get-AzureApiManagementAuthorizationServer -Context $context -ServerId $serverId + $server = Get-AzureRMApiManagementAuthorizationServer -Context $context -ServerId $serverId Assert-AreEqual $serverId $server.ServerId Assert-AreEqual $name $server.Name @@ -1290,7 +1290,7 @@ Param($resourceGroupName, $serviceName) $supportState = $false $tokenBodyParameters = @{'tokenname1'='tokenvalue1'} - $server = Set-AzureApiManagementAuthorizationServer -Context $context -ServerId $serverId -Name $name -Description $description ` + $server = Set-AzureRMApiManagementAuthorizationServer -Context $context -ServerId $serverId -Name $name -Description $description ` -ClientRegistrationPageUrl $clientRegistrationEndpoint -AuthorizationEndpointUrl $authorizationEndpoint ` -TokenEndpointUrl $tokenEndpoint -ClientId $clientId -ClientSecret $clientSecret -AuthorizationRequestMethods $authorizationMethods ` -GrantTypes $grantTypes -ClientAuthenticationMethods $clientAuthenticationMethods -TokenBodyParameters $tokenBodyParameters ` @@ -1320,7 +1320,7 @@ Param($resourceGroupName, $serviceName) Assert-AreEqual $supportState $server.SupportState Assert-AreEqual $tokenBodyParameters.Count $server.TokenBodyParameters.Count - $server = Get-AzureApiManagementAuthorizationServer -Context $context -ServerId $serverId + $server = Get-AzureRMApiManagementAuthorizationServer -Context $context -ServerId $serverId Assert-AreEqual $serverId $server.ServerId Assert-AreEqual $name $server.Name @@ -1351,14 +1351,14 @@ Param($resourceGroupName, $serviceName) finally { # remove created server - $removed = Remove-AzureApiManagementAuthorizationServer -Context $context -ServerId $serverId -Force -PassThru + $removed = Remove-AzureRMApiManagementAuthorizationServer -Context $context -ServerId $serverId -Force -PassThru Assert-True {$removed} $server = $null try { # check it was removed - $server = Get-AzureApiManagementAuthorizationServer -Context $context -ServerId $serverId + $server = Get-AzureRMApiManagementAuthorizationServer -Context $context -ServerId $serverId } catch { diff --git a/src/ResourceManager/ApiManagement/Commands.SMAPI.Test/ScenarioTests/Common.ps1 b/src/ResourceManager/ApiManagement/Commands.SMAPI.Test/ScenarioTests/Common.ps1 index eb8f458bf182..0275adb24b47 100644 --- a/src/ResourceManager/ApiManagement/Commands.SMAPI.Test/ScenarioTests/Common.ps1 +++ b/src/ResourceManager/ApiManagement/Commands.SMAPI.Test/ScenarioTests/Common.ps1 @@ -50,6 +50,6 @@ Gets all locations for a provider #> function Get-ProviderLocations($provider) { - $location = Get-AzureLocation | where {$_.Name -eq $provider} + $location = Get-AzureRMLocation | where {$_.Name -eq $provider} $location.Locations } \ No newline at end of file diff --git a/src/ResourceManager/ApiManagement/Commands.SMAPI.Test/packages.config b/src/ResourceManager/ApiManagement/Commands.SMAPI.Test/packages.config index 3012e66b5419..c1ab2c95bd00 100644 --- a/src/ResourceManager/ApiManagement/Commands.SMAPI.Test/packages.config +++ b/src/ResourceManager/ApiManagement/Commands.SMAPI.Test/packages.config @@ -2,13 +2,13 @@ - + - - + + diff --git a/src/ResourceManager/Automation/Commands.Automation.Test/Commands.ResourceManagement.Automation.Test.csproj b/src/ResourceManager/Automation/Commands.Automation.Test/Commands.ResourceManagement.Automation.Test.csproj index 4f40978789d4..a68d8c01cf0d 100644 --- a/src/ResourceManager/Automation/Commands.Automation.Test/Commands.ResourceManagement.Automation.Test.csproj +++ b/src/ResourceManager/Automation/Commands.Automation.Test/Commands.ResourceManagement.Automation.Test.csproj @@ -1,5 +1,6 @@  + Debug AnyCPU @@ -17,6 +18,8 @@ ..\..\..\ true + + true @@ -55,7 +58,7 @@ False - ..\..\..\packages\Microsoft.Azure.Common.Authentication.1.1.3-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + ..\..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll ..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll @@ -65,7 +68,7 @@ ..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll - ..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5687.28567-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll + ..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5715.36130-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll True @@ -163,13 +166,13 @@ - - {3b48a77b-5956-4a62-9081-92ba04b02b27} - Commands.Common.Test + + {3819d8a7-c62c-4c47-8ddd-0332d9ce1252} + Commands.ResourceManager.Common - - {5ee72c53-1720-4309-b54b-5fb79703195f} - Commands.Common + + {c1bda476-a5cc-4394-914d-48b0ec31a710} + Commands.ScenarioTests.Common {90def35a-f7ff-40d0-b008-f489a4c092db} @@ -187,6 +190,12 @@ + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + - + \ No newline at end of file diff --git a/src/ServiceManagement/Storage/Commands.Storage.StorageTestLib/packages.config b/src/ServiceManagement/Storage/Commands.Storage.StorageTestLib/packages.config index c6e9c879a28b..23ae268ea470 100644 --- a/src/ServiceManagement/Storage/Commands.Storage.StorageTestLib/packages.config +++ b/src/ServiceManagement/Storage/Commands.Storage.StorageTestLib/packages.config @@ -1,5 +1,6 @@  + @@ -7,5 +8,5 @@ - - + + \ No newline at end of file diff --git a/src/ServiceManagement/Storage/Commands.Storage.Test/Commands.Storage.Test.csproj b/src/ServiceManagement/Storage/Commands.Storage.Test/Commands.Storage.Test.csproj index 07028ab67926..62de3cd7049f 100644 --- a/src/ServiceManagement/Storage/Commands.Storage.Test/Commands.Storage.Test.csproj +++ b/src/ServiceManagement/Storage/Commands.Storage.Test/Commands.Storage.Test.csproj @@ -1,6 +1,6 @@  - + Debug AnyCPU @@ -20,7 +20,8 @@ true ..\..\..\ - 14b3fe9f + + true @@ -58,17 +59,21 @@ False - ..\..\..\packages\Microsoft.Azure.Common.Authentication.1.1.3-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + ..\..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll ..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll + + ..\..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll + True + False ..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll - - ..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5687.28567-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll + + ..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5715.36130-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll True @@ -230,6 +235,10 @@ {3b48a77b-5956-4a62-9081-92ba04b02b27} Commands.Common.Test + + {c1bda476-a5cc-4394-914d-48b0ec31a710} + Commands.ScenarioTests.Common + {08cf7da7-0392-4a19-b79b-e1ff67cdb81a} Commands.Storage @@ -275,9 +284,9 @@ - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - +