Skip to content

Commit d1f8f02

Browse files
committed
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
2 parents 39c83ea + 6b1a958 commit d1f8f02

File tree

48 files changed

+13614
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+13614
-486
lines changed

setup/azurecmdfiles.wxi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,9 @@
12671267
<Component Id="cmpF417A81D5F1E4FA1121F5CF7B9DC8439" Guid="*">
12681268
<File Id="fil43DE88B90B4EAEB16296A84082C1DCF1" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\HDInsight\Microsoft.Azure.Commands.HDInsight.dll" />
12691269
</Component>
1270+
<Component Id="cmp278E6AC149924003FD07F271A0D39B73" Guid="*">
1271+
<File Id="filB6023ABB5409C60A6392D145BB79604E" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\HDInsight\Microsoft.Azure.Commands.HDInsight.dll-help.psd1" />
1272+
</Component>
12701273
<Component Id="cmp0CEB7817889A2764028EDD1A3E0955C8" Guid="*">
12711274
<File Id="fil843773A2EA2CC25507CE5DFA567E6722" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\HDInsight\Microsoft.Azure.Common.Authentication.dll" />
12721275
</Component>
@@ -5352,6 +5355,7 @@
53525355
<ComponentRef Id="cmpAB177D1334F111EB52C17D3C8B63D74F" />
53535356
<ComponentRef Id="cmp1516DA5C976539D7953783DBE0C35FC0" />
53545357
<ComponentRef Id="cmpF417A81D5F1E4FA1121F5CF7B9DC8439" />
5358+
<ComponentRef Id="cmp278E6AC149924003FD07F271A0D39B73" />
53555359
<ComponentRef Id="cmp0CEB7817889A2764028EDD1A3E0955C8" />
53565360
<ComponentRef Id="cmp12254838A1AB62028019D3E828B5EDBC" />
53575361
<ComponentRef Id="cmpCEC1013D8449BCE69C91DCA01F609D2E" />

src/Common/Commands.Common/AzurePSCmdlet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ protected AzureContext GetCurrentContext()
117117

118118
protected static void InitializeTokenCaches()
119119
{
120-
DefaultMemoryTokenCache = new TokenCache();
120+
DefaultMemoryTokenCache = TokenCache.DefaultShared;
121121
if (!string.IsNullOrWhiteSpace(AzureSession.ProfileDirectory) &&
122122
!string.IsNullOrWhiteSpace(AzureSession.TokenCacheFile))
123123
{

src/Common/Commands.Common/Properties/Resources.Designer.cs

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Common/Commands.Common/Properties/Resources.resx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,10 +1361,9 @@ use and privacy statement at &lt;url&gt; and (c) agree to sharing my contact inf
13611361
<data name="SwitchAzureModeDeprecated" xml:space="preserve">
13621362
<value>The Switch-AzureMode cmdlet is deprecated and will be removed in a future release.</value>
13631363
</data>
1364-
<data name="ComputeCloudExceptionOperationIdMessage" xml:space="preserve">
1365-
<value>OperationID : '{0}'</value>
1366-
</data>
1367-
<!-- DSC -->
1364+
<data name="ComputeCloudExceptionOperationIdMessage" xml:space="preserve">
1365+
<value>OperationID : '{0}'</value>
1366+
</data>
13681367
<data name="PublishVMDscExtensionGetDscResourceFailed" xml:space="preserve">
13691368
<value>Cannot get module for DscResource '{0}'. Possible solutions:
13701369
1) Specify -ModuleName for Import-DscResource in your configuration.
@@ -1466,4 +1465,7 @@ The file needs to be a PowerShell script (.ps1 or .psm1).</value>
14661465
<data name="AzureVMDscInvalidConfigurationDataFile" xml:space="preserve">
14671466
<value>The configuration data must be a .psd1 file</value>
14681467
</data>
1468+
<data name="CannotChangeBuiltinEnvironment" xml:space="preserve">
1469+
<value>Cannot change built-in environment {0}.</value>
1470+
</data>
14691471
</root>

src/Common/Commands.Profile/Commands.Profile.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
<Compile Include="Environment\SetAzureEnvironment.cs" />
137137
<Compile Include="Environment\GetAzureEnvironment.cs" />
138138
<Compile Include="Models\AzureProfileSettings.cs" />
139+
<Compile Include="Models\PSAzureEnvironment.cs" />
139140
<Compile Include="Models\PSAzureSubscription.cs" />
140141
<Compile Include="Models\PSAzureSubscriptionExtended.cs" />
141142
<Compile Include="Profile\SelectAzureProfile.cs" />

src/Common/Commands.Profile/Environment/AddAzureEnvironment.cs

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System.Management.Automation;
1616
using System.Security.Permissions;
1717
using Microsoft.Azure.Common.Authentication.Models;
18+
using Microsoft.WindowsAzure.Commands.Profile.Models;
1819
using Microsoft.WindowsAzure.Commands.Utilities.Profile;
1920
using System.Collections.Generic;
2021
using System;
@@ -26,7 +27,7 @@ namespace Microsoft.WindowsAzure.Commands.Profile
2627
/// <summary>
2728
/// Adds a new Microsoft Azure environment.
2829
/// </summary>
29-
[Cmdlet(VerbsCommon.Add, "AzureEnvironment"), OutputType(typeof(AzureEnvironment))]
30+
[Cmdlet(VerbsCommon.Add, "AzureEnvironment"), OutputType(typeof(PSAzureEnvironment))]
3031
public class AddAzureEnvironmentCommand : SubscriptionCmdletBase
3132
{
3233
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true)]
@@ -36,21 +37,26 @@ public class AddAzureEnvironmentCommand : SubscriptionCmdletBase
3637
public string PublishSettingsFileUrl { get; set; }
3738

3839
[Parameter(Position = 2, Mandatory = false, ValueFromPipelineByPropertyName = true)]
40+
[Alias("ServiceManagement", "ServiceManagementUrl")]
3941
public string ServiceEndpoint { get; set; }
4042

4143
[Parameter(Position = 3, Mandatory = false, ValueFromPipelineByPropertyName = true)]
4244
public string ManagementPortalUrl { get; set; }
4345

4446
[Parameter(Position = 4, Mandatory = false, HelpMessage = "The storage endpoint")]
47+
[Alias("StorageEndpointSuffix")]
4548
public string StorageEndpoint { get; set; }
4649

4750
[Parameter(Position = 5, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The URI for the Active Directory service for this environment")]
51+
[Alias("AdEndpointUrl", "ActiveDirectory", "ActiveDirectoryAuthority")]
4852
public string ActiveDirectoryEndpoint { get; set; }
4953

5054
[Parameter(Position = 6, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The cloud service endpoint")]
55+
[Alias("ResourceManager", "ResourceManagerUrl")]
5156
public string ResourceManagerEndpoint { get; set; }
5257

5358
[Parameter(Position = 7, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The public gallery endpoint")]
59+
[Alias("Gallery", "GalleryUrl")]
5460
public string GalleryEndpoint { get; set; }
5561

5662
[Parameter(Position = 8, Mandatory = false, ValueFromPipelineByPropertyName = true,
@@ -59,6 +65,7 @@ public class AddAzureEnvironmentCommand : SubscriptionCmdletBase
5965

6066
[Parameter(Position = 9, Mandatory = false, ValueFromPipelineByPropertyName = true,
6167
HelpMessage = "The AD Graph Endpoint.")]
68+
[Alias("Graph", "GraphUrl")]
6269
public string GraphEndpoint { get; set; }
6370

6471
[Parameter(Position = 10, Mandatory = false, ValueFromPipelineByPropertyName = true,
@@ -70,8 +77,21 @@ public class AddAzureEnvironmentCommand : SubscriptionCmdletBase
7077
public string AzureKeyVaultServiceEndpointResourceId { get; set; }
7178

7279
[Parameter(Position = 12, Mandatory = false, ValueFromPipelineByPropertyName = true,
80+
HelpMessage = "Dns suffix of Traffic Manager service.")]
81+
public string TrafficManagerDnsSuffix { get; set; }
82+
83+
[Parameter(Position = 13, Mandatory = false, ValueFromPipelineByPropertyName = true,
84+
HelpMessage = "Dns suffix of Sql databases created in this environment.")]
85+
public string SqlDatabaseDnsSuffix { get; set; }
86+
87+
[Parameter(Position = 14, Mandatory = false, ValueFromPipelineByPropertyName = true,
7388
HelpMessage = "Enable ADFS authentication by disabling the authority validation")]
74-
public SwitchParameter EnableADFSAuthentication { get; set; }
89+
[Alias("OnPremise")]
90+
public SwitchParameter EnableAdfsAuthentication { get; set; }
91+
92+
[Parameter(Position = 15, Mandatory = false, ValueFromPipelineByPropertyName = true,
93+
HelpMessage = "The default tenant for this environment.")]
94+
public string AdTenant { get; set; }
7595

7696
public AddAzureEnvironmentCommand() : base(true) { }
7797

@@ -81,7 +101,7 @@ public override void ExecuteCmdlet()
81101
var newEnvironment = new AzureEnvironment
82102
{
83103
Name = Name,
84-
OnPremise = EnableADFSAuthentication
104+
OnPremise = EnableAdfsAuthentication
85105
};
86106
newEnvironment.Endpoints[AzureEnvironment.Endpoint.PublishSettingsFileUrl] = PublishSettingsFileUrl;
87107
newEnvironment.Endpoints[AzureEnvironment.Endpoint.ServiceManagement] = ServiceEndpoint;
@@ -94,14 +114,11 @@ public override void ExecuteCmdlet()
94114
newEnvironment.Endpoints[AzureEnvironment.Endpoint.Graph] = GraphEndpoint;
95115
newEnvironment.Endpoints[AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix] = AzureKeyVaultDnsSuffix;
96116
newEnvironment.Endpoints[AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId] = AzureKeyVaultServiceEndpointResourceId;
97-
117+
newEnvironment.Endpoints[AzureEnvironment.Endpoint.TrafficManagerDnsSuffix] = TrafficManagerDnsSuffix;
118+
newEnvironment.Endpoints[AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix] = SqlDatabaseDnsSuffix;
119+
newEnvironment.Endpoints[AzureEnvironment.Endpoint.AdTenant] = AdTenant;
98120
ProfileClient.AddOrSetEnvironment(newEnvironment);
99-
List<object> args = new List<object> { "Name", newEnvironment.Name };
100-
foreach (AzureEnvironment.Endpoint property in Enum.GetValues(typeof(AzureEnvironment.Endpoint)))
101-
{
102-
args.AddRange(new object[] { property, newEnvironment.GetEndpoint(property) });
103-
}
104-
WriteObject(base.ConstructPSObject(null, args.ToArray()));
121+
WriteObject((PSAzureEnvironment)newEnvironment);
105122
}
106123
}
107124
}

src/Common/Commands.Profile/Environment/GetAzureEnvironment.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System.Collections.Generic;
16+
using System.Linq;
1617
using System.Management.Automation;
1718
using System.Security.Permissions;
1819
using Microsoft.Azure.Common.Authentication.Models;
20+
using Microsoft.WindowsAzure.Commands.Profile.Models;
1921
using Microsoft.WindowsAzure.Commands.Utilities.Profile;
2022
using System;
2123

@@ -24,7 +26,7 @@ namespace Microsoft.WindowsAzure.Commands.Profile
2426
/// <summary>
2527
/// Gets the available Microsoft Azure environments.
2628
/// </summary>
27-
[Cmdlet(VerbsCommon.Get, "AzureEnvironment"), OutputType(typeof(List<AzureEnvironment>))]
29+
[Cmdlet(VerbsCommon.Get, "AzureEnvironment"), OutputType(typeof(PSAzureEnvironment))]
2830
public class GetAzureEnvironmentCommand : SubscriptionCmdletBase
2931
{
3032
[Parameter(Position = 0, Mandatory = false, ValueFromPipelineByPropertyName = true,
@@ -36,18 +38,8 @@ public GetAzureEnvironmentCommand() : base(false) { }
3638
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
3739
public override void ExecuteCmdlet()
3840
{
39-
List<AzureEnvironment> environments = ProfileClient.ListEnvironments(Name);
40-
List<PSObject> output = new List<PSObject>();
41-
foreach (AzureEnvironment e in environments)
42-
{
43-
List<object> args = new List<object> { "Name", e.Name };
44-
foreach (AzureEnvironment.Endpoint property in Enum.GetValues(typeof(AzureEnvironment.Endpoint)))
45-
{
46-
args.AddRange(new object[] { property, e.GetEndpoint(property) });
47-
}
48-
output.Add(base.ConstructPSObject(null, args.ToArray()));
49-
}
50-
WriteObject(output, true);
41+
List<PSAzureEnvironment> environments = ProfileClient.ListEnvironments(Name).Select((e) => (PSAzureEnvironment)e).ToList();
42+
WriteObject(environments, true);
5143
}
5244
}
5345
}

src/Common/Commands.Profile/Environment/RemoveAzureEnvironment.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using System.Security.Permissions;
1717
using Microsoft.Azure.Common.Authentication.Models;
1818
using Microsoft.WindowsAzure.Commands.Common.Properties;
19+
using Microsoft.WindowsAzure.Commands.Profile.Models;
1920
using Microsoft.WindowsAzure.Commands.Utilities.Profile;
2021

2122
namespace Microsoft.WindowsAzure.Commands.Profile
@@ -25,7 +26,7 @@ namespace Microsoft.WindowsAzure.Commands.Profile
2526
/// <summary>
2627
/// Removes a Microsoft Azure environment.
2728
/// </summary>
28-
[Cmdlet(VerbsCommon.Remove, "AzureEnvironment"), OutputType(typeof(AzureEnvironment))]
29+
[Cmdlet(VerbsCommon.Remove, "AzureEnvironment"), OutputType(typeof(PSAzureEnvironment))]
2930
public class RemoveAzureEnvironmentCommand : SubscriptionCmdletBase
3031
{
3132
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true,
@@ -50,7 +51,7 @@ public override void ExecuteCmdlet()
5051

5152
public void RemoveEnvironmentProcess()
5253
{
53-
WriteObject(ProfileClient.RemoveEnvironment(Name));
54+
WriteObject((PSAzureEnvironment)(ProfileClient.RemoveEnvironment(Name)));
5455
}
5556
}
5657
}

src/Common/Commands.Profile/Environment/SetAzureEnvironment.cs

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using System;
16+
using System.Globalization;
1517
using System.Management.Automation;
1618
using System.Security.Permissions;
1719
using Microsoft.Azure.Common.Authentication.Models;
20+
using Microsoft.WindowsAzure.Commands.Common.Properties;
21+
using Microsoft.WindowsAzure.Commands.Profile.Models;
1822
using Microsoft.WindowsAzure.Commands.Utilities.Profile;
1923

2024
namespace Microsoft.WindowsAzure.Commands.Profile
@@ -23,7 +27,7 @@ namespace Microsoft.WindowsAzure.Commands.Profile
2327
/// <summary>
2428
/// Sets a Microsoft Azure environment.
2529
/// </summary>
26-
[Cmdlet(VerbsCommon.Set, "AzureEnvironment"), OutputType(typeof(AzureEnvironment))]
30+
[Cmdlet(VerbsCommon.Set, "AzureEnvironment"), OutputType(typeof(PSAzureEnvironment))]
2731
public class SetAzureEnvironmentCommand : SubscriptionCmdletBase
2832
{
2933
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true)]
@@ -33,22 +37,26 @@ public class SetAzureEnvironmentCommand : SubscriptionCmdletBase
3337
public string PublishSettingsFileUrl { get; set; }
3438

3539
[Parameter(Position = 2, Mandatory = false, ValueFromPipelineByPropertyName = true)]
40+
[Alias("ServiceManagement", "ServiceManagementUrl")]
3641
public string ServiceEndpoint { get; set; }
3742

3843
[Parameter(Position = 3, Mandatory = false, ValueFromPipelineByPropertyName = true)]
3944
public string ManagementPortalUrl { get; set; }
4045

4146
[Parameter(Position = 4, Mandatory = false, HelpMessage = "The storage endpoint")]
47+
[Alias("StorageEndpointSuffix")]
4248
public string StorageEndpoint { get; set; }
4349

4450
[Parameter(Position = 5, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Active directory endpoint")]
45-
[Alias("AdEndpointUrl")]
51+
[Alias("AdEndpointUrl", "ActiveDirectory", "ActiveDirectoryAuthority")]
4652
public string ActiveDirectoryEndpoint { get; set; }
4753

4854
[Parameter(Position = 6, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The cloud service endpoint")]
55+
[Alias("ResourceManager", "ResourceManagerUrl")]
4956
public string ResourceManagerEndpoint { get; set; }
5057

5158
[Parameter(Position = 7, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The public gallery endpoint")]
59+
[Alias("Gallery", "GalleryUrl")]
5260
public string GalleryEndpoint { get; set; }
5361

5462
[Parameter(Position = 8, Mandatory = false, ValueFromPipelineByPropertyName = true,
@@ -57,6 +65,7 @@ public class SetAzureEnvironmentCommand : SubscriptionCmdletBase
5765

5866
[Parameter(Position = 9, Mandatory = false, ValueFromPipelineByPropertyName = true,
5967
HelpMessage = "The AD Graph Endpoint.")]
68+
[Alias("Graph", "GraphUrl")]
6069
public string GraphEndpoint { get; set; }
6170

6271
[Parameter(Position = 10, Mandatory = false, ValueFromPipelineByPropertyName = true,
@@ -67,12 +76,35 @@ public class SetAzureEnvironmentCommand : SubscriptionCmdletBase
6776
HelpMessage = "Resource identifier of Azure Key Vault data service that is the recipient of the requested token.")]
6877
public string AzureKeyVaultServiceEndpointResourceId { get; set; }
6978

79+
[Parameter(Position = 12, Mandatory = false, ValueFromPipelineByPropertyName = true,
80+
HelpMessage = "Dns suffix of Traffic Manager service.")]
81+
public string TrafficManagerDnsSuffix { get; set; }
82+
83+
[Parameter(Position = 13, Mandatory = false, ValueFromPipelineByPropertyName = true,
84+
HelpMessage = "Dns suffix of Sql databases created in this environment.")]
85+
public string SqlDatabaseDnsSuffix { get; set; }
86+
87+
[Parameter(Position = 14, Mandatory = false, ValueFromPipelineByPropertyName = true,
88+
HelpMessage = "Determines whether to enable ADFS authentication, or to use AAD authentication instead. This value is normally true only for Azure Stack endpoints.")]
89+
[Alias("OnPremise")]
90+
public SwitchParameter EnableAdfsAuthentication { get; set; }
91+
92+
[Parameter(Position = 15, Mandatory = false, ValueFromPipelineByPropertyName = true,
93+
HelpMessage = "The default tenant for this environment.")]
94+
public string AdTenant { get; set; }
95+
7096
public SetAzureEnvironmentCommand() : base(true) { }
7197

7298
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
7399
public override void ExecuteCmdlet()
74100
{
75-
var newEnvironment = new AzureEnvironment { Name = Name };
101+
if ((Name == "AzureCloud") || (Name == "AzureChinaCloud"))
102+
{
103+
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
104+
Resources.CannotChangeBuiltinEnvironment, Name));
105+
}
106+
107+
var newEnvironment = new AzureEnvironment { Name = Name, OnPremise = EnableAdfsAuthentication };
76108
if (ProfileClient.Profile.Environments.ContainsKey(Name))
77109
{
78110
newEnvironment = ProfileClient.Profile.Environments[Name];
@@ -88,10 +120,13 @@ public override void ExecuteCmdlet()
88120
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.Graph, GraphEndpoint);
89121
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix, AzureKeyVaultDnsSuffix);
90122
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId, AzureKeyVaultServiceEndpointResourceId);
123+
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.TrafficManagerDnsSuffix, TrafficManagerDnsSuffix);
124+
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix, SqlDatabaseDnsSuffix);
125+
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.AdTenant, AdTenant);
91126

92127
ProfileClient.AddOrSetEnvironment(newEnvironment);
93128

94-
WriteObject(newEnvironment);
129+
WriteObject((PSAzureEnvironment)newEnvironment);
95130
}
96131

97132
private void SetEndpointIfProvided(AzureEnvironment newEnvironment, AzureEnvironment.Endpoint endpoint, string property)

0 commit comments

Comments
 (0)