12
12
// limitations under the License.
13
13
// ----------------------------------------------------------------------------------
14
14
15
+ using System ;
16
+ using System . Globalization ;
15
17
using System . Management . Automation ;
16
18
using System . Security . Permissions ;
17
19
using Microsoft . Azure . Common . Authentication . Models ;
20
+ using Microsoft . WindowsAzure . Commands . Common . Properties ;
21
+ using Microsoft . WindowsAzure . Commands . Profile . Models ;
18
22
using Microsoft . WindowsAzure . Commands . Utilities . Profile ;
19
23
20
24
namespace Microsoft . WindowsAzure . Commands . Profile
@@ -23,7 +27,7 @@ namespace Microsoft.WindowsAzure.Commands.Profile
23
27
/// <summary>
24
28
/// Sets a Microsoft Azure environment.
25
29
/// </summary>
26
- [ Cmdlet ( VerbsCommon . Set , "AzureEnvironment" ) , OutputType ( typeof ( AzureEnvironment ) ) ]
30
+ [ Cmdlet ( VerbsCommon . Set , "AzureEnvironment" ) , OutputType ( typeof ( PSAzureEnvironment ) ) ]
27
31
public class SetAzureEnvironmentCommand : SubscriptionCmdletBase
28
32
{
29
33
[ Parameter ( Position = 0 , Mandatory = true , ValueFromPipelineByPropertyName = true ) ]
@@ -33,22 +37,26 @@ public class SetAzureEnvironmentCommand : SubscriptionCmdletBase
33
37
public string PublishSettingsFileUrl { get ; set ; }
34
38
35
39
[ Parameter ( Position = 2 , Mandatory = false , ValueFromPipelineByPropertyName = true ) ]
40
+ [ Alias ( "ServiceManagement" , "ServiceManagementUrl" ) ]
36
41
public string ServiceEndpoint { get ; set ; }
37
42
38
43
[ Parameter ( Position = 3 , Mandatory = false , ValueFromPipelineByPropertyName = true ) ]
39
44
public string ManagementPortalUrl { get ; set ; }
40
45
41
46
[ Parameter ( Position = 4 , Mandatory = false , HelpMessage = "The storage endpoint" ) ]
47
+ [ Alias ( "StorageEndpointSuffix" ) ]
42
48
public string StorageEndpoint { get ; set ; }
43
49
44
50
[ Parameter ( Position = 5 , Mandatory = false , ValueFromPipelineByPropertyName = true , HelpMessage = "Active directory endpoint" ) ]
45
- [ Alias ( "AdEndpointUrl" ) ]
51
+ [ Alias ( "AdEndpointUrl" , "ActiveDirectory" , "ActiveDirectoryAuthority" ) ]
46
52
public string ActiveDirectoryEndpoint { get ; set ; }
47
53
48
54
[ Parameter ( Position = 6 , Mandatory = false , ValueFromPipelineByPropertyName = true , HelpMessage = "The cloud service endpoint" ) ]
55
+ [ Alias ( "ResourceManager" , "ResourceManagerUrl" ) ]
49
56
public string ResourceManagerEndpoint { get ; set ; }
50
57
51
58
[ Parameter ( Position = 7 , Mandatory = false , ValueFromPipelineByPropertyName = true , HelpMessage = "The public gallery endpoint" ) ]
59
+ [ Alias ( "Gallery" , "GalleryUrl" ) ]
52
60
public string GalleryEndpoint { get ; set ; }
53
61
54
62
[ Parameter ( Position = 8 , Mandatory = false , ValueFromPipelineByPropertyName = true ,
@@ -57,6 +65,7 @@ public class SetAzureEnvironmentCommand : SubscriptionCmdletBase
57
65
58
66
[ Parameter ( Position = 9 , Mandatory = false , ValueFromPipelineByPropertyName = true ,
59
67
HelpMessage = "The AD Graph Endpoint." ) ]
68
+ [ Alias ( "Graph" , "GraphUrl" ) ]
60
69
public string GraphEndpoint { get ; set ; }
61
70
62
71
[ Parameter ( Position = 10 , Mandatory = false , ValueFromPipelineByPropertyName = true ,
@@ -67,12 +76,35 @@ public class SetAzureEnvironmentCommand : SubscriptionCmdletBase
67
76
HelpMessage = "Resource identifier of Azure Key Vault data service that is the recipient of the requested token." ) ]
68
77
public string AzureKeyVaultServiceEndpointResourceId { get ; set ; }
69
78
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
+
70
96
public SetAzureEnvironmentCommand ( ) : base ( true ) { }
71
97
72
98
[ PermissionSet ( SecurityAction . Demand , Name = "FullTrust" ) ]
73
99
public override void ExecuteCmdlet ( )
74
100
{
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 } ;
76
108
if ( ProfileClient . Profile . Environments . ContainsKey ( Name ) )
77
109
{
78
110
newEnvironment = ProfileClient . Profile . Environments [ Name ] ;
@@ -88,10 +120,13 @@ public override void ExecuteCmdlet()
88
120
SetEndpointIfProvided ( newEnvironment , AzureEnvironment . Endpoint . Graph , GraphEndpoint ) ;
89
121
SetEndpointIfProvided ( newEnvironment , AzureEnvironment . Endpoint . AzureKeyVaultDnsSuffix , AzureKeyVaultDnsSuffix ) ;
90
122
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 ) ;
91
126
92
127
ProfileClient . AddOrSetEnvironment ( newEnvironment ) ;
93
128
94
- WriteObject ( newEnvironment ) ;
129
+ WriteObject ( ( PSAzureEnvironment ) newEnvironment ) ;
95
130
}
96
131
97
132
private void SetEndpointIfProvided ( AzureEnvironment newEnvironment , AzureEnvironment . Endpoint endpoint , string property )
0 commit comments