Skip to content

Commit b153bff

Browse files
committed
code change
1 parent 56839c5 commit b153bff

11 files changed

+263
-2
lines changed

src/Accounts/Accounts/AzureRmAlias/Mappings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,10 @@
12881288
"New-AzApplicationGatewayFrontendPort": "New-AzureRmApplicationGatewayFrontendPort",
12891289
"Remove-AzApplicationGatewayFrontendPort": "Remove-AzureRmApplicationGatewayFrontendPort",
12901290
"Set-AzApplicationGatewayFrontendPort": "Set-AzureRmApplicationGatewayFrontendPort",
1291+
"Get-AzApplicationGatewayIdentity": "Get-AzureRmApplicationGatewayIdentity",
1292+
"New-AzApplicationGatewayIdentity": "New-AzureRmApplicationGatewayIdentity",
1293+
"Remove-AzApplicationGatewayIdentity": "Remove-AzureRmApplicationGatewayIdentity",
1294+
"Set-AzApplicationGatewayIdentity": "Set-AzureRmApplicationGatewayIdentity",
12911295
"Add-AzApplicationGatewayIPConfiguration": "Add-AzureRmApplicationGatewayIPConfiguration",
12921296
"Get-AzApplicationGatewayIPConfiguration": "Get-AzureRmApplicationGatewayIPConfiguration",
12931297
"New-AzApplicationGatewayIPConfiguration": "New-AzureRmApplicationGatewayIPConfiguration",

src/Network/Network.Test/Network.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<PackageReference Include="Microsoft.Azure.Management.ContainerInstance" Version="2.0.0" />
2121
<PackageReference Include="Microsoft.Azure.Management.Redis" Version="4.4.1" />
2222
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.19.0-preview" />
23+
<PackageReference Include="Microsoft.Azure.Management.ManagedServiceIdentity" Version="0.10.0-preview" />
2324
</ItemGroup>
2425

2526
<ItemGroup>

src/Network/Network.Test/NetworkResourcesController.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Microsoft.Azure.Commands.Common.Authentication;
1616
using Microsoft.Azure.Management.Compute;
1717
using Microsoft.Azure.Management.ContainerInstance;
18+
using Microsoft.Azure.Management.ManagedServiceIdentity;
1819
using Microsoft.Azure.Management.Network;
1920
using Microsoft.Azure.Management.Redis;
2021
using Microsoft.Azure.Management.OperationalInsights;
@@ -48,6 +49,8 @@ public sealed class NetworkResourcesController
4849

4950
public OperationalInsightsManagementClient OperationalInsightsManagementClient { get; private set; }
5051

52+
public ManagedServiceIdentityClient ManagedServiceIdentityClient { get; private set; }
53+
5154
public static NetworkResourcesController NewInstance => new NetworkResourcesController();
5255

5356
public NetworkResourcesController()
@@ -64,7 +67,8 @@ public void RunPsTest(XunitTracingInterceptor logger, params string[] scripts)
6467
{"Microsoft.Compute", null},
6568
{"Microsoft.Features", null},
6669
{"Microsoft.Authorization", null},
67-
{"Microsoft.Storage", null}
70+
{"Microsoft.Storage", null},
71+
{"Microsoft.ManagedServiceIdentity", null}
6872
};
6973
var providersToIgnore = new Dictionary<string, string>
7074
{
@@ -128,6 +132,7 @@ public void RunPsTestWorkflow(
128132
_helper.GetRMModulePath("AzureRM.Compute.psd1"),
129133
_helper.GetRMModulePath("AzureRM.ContainerInstance.psd1"),
130134
_helper.GetRMModulePath("AzureRM.OperationalInsights.psd1"),
135+
_helper.GetRMModulePath("AzureRM.ManagedServiceIdentity.psd1"),
131136
"AzureRM.Storage.ps1",
132137
_helper.GetRMModulePath("AzureRM.Storage.psd1"),
133138
"AzureRM.Resources.ps1");
@@ -161,6 +166,7 @@ private void SetupManagementClients(MockContext context)
161166
StorageManagementClient = GetStorageManagementClient(context);
162167
RedisManagementClient = GetRedisManagementClient(context);
163168
OperationalInsightsManagementClient = GetOperationalInsightsManagementClient(context);
169+
ManagedServiceIdentityClient = GetManagedServiceIdentityClient(context);
164170

165171
_helper.SetupManagementClients(
166172
resourceManagerResourceManagementClient,
@@ -169,7 +175,13 @@ private void SetupManagementClients(MockContext context)
169175
ContainerInstanceManagementClient,
170176
StorageManagementClient,
171177
RedisManagementClient,
172-
OperationalInsightsManagementClient);
178+
OperationalInsightsManagementClient,
179+
ManagedServiceIdentityClient);
180+
}
181+
182+
private static ManagedServiceIdentityClient GetManagedServiceIdentityClient(MockContext context)
183+
{
184+
return context.GetServiceClient<ManagedServiceIdentityClient>(TestEnvironmentFactory.GetTestEnvironment());
173185
}
174186

175187
private static NetworkManagementClient GetNetworkManagementClient(MockContext context)
@@ -203,3 +215,4 @@ private static ContainerInstanceManagementClient GetContainerInstanceManagementC
203215
}
204216
}
205217
}
218+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.Management.Automation;
18+
using Microsoft.Azure.Commands.Network.Models;
19+
using MNM = Microsoft.Azure.Management.Network.Models;
20+
21+
namespace Microsoft.Azure.Commands.Network
22+
{
23+
public class AzureApplicationGatewayIdentityBase : NetworkBaseCmdlet
24+
{
25+
[Parameter(
26+
Mandatory = true,
27+
ValueFromPipelineByPropertyName = true,
28+
HelpMessage = "ResourceId of the user assigned identity to be assigned to Application Gateway.")]
29+
[ValidateNotNullOrEmpty]
30+
[Alias("UserAssignedIdentity")]
31+
public string UserAssignedIdentityId { get; set; }
32+
33+
public override void ExecuteCmdlet()
34+
{
35+
base.ExecuteCmdlet();
36+
}
37+
38+
public PSManagedServiceIdentity NewObject()
39+
{
40+
var identity = new PSManagedServiceIdentity
41+
{
42+
Type = MNM.ResourceIdentityType.UserAssigned,
43+
UserAssignedIdentities = new Dictionary<string, PSManagedServiceIdentityUserAssignedIdentitiesValue>
44+
{
45+
{ this.UserAssignedIdentityId, new PSManagedServiceIdentityUserAssignedIdentitiesValue() }
46+
}
47+
};
48+
49+
return identity;
50+
}
51+
}
52+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Network.Models;
16+
using System.Management.Automation;
17+
18+
namespace Microsoft.Azure.Commands.Network
19+
{
20+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApplicationGatewayIdentity"), OutputType(typeof(PSManagedServiceIdentity))]
21+
public class GetAzureApplicationGatewayIdentityCommand : NetworkBaseCmdlet
22+
{
23+
[Parameter(
24+
Mandatory = true,
25+
ValueFromPipeline = true,
26+
HelpMessage = "The applicationGateway")]
27+
public PSApplicationGateway ApplicationGateway { get; set; }
28+
29+
public override void ExecuteCmdlet()
30+
{
31+
base.ExecuteCmdlet();
32+
WriteObject(this.ApplicationGateway.Identity, true);
33+
}
34+
}
35+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Collections.Generic;
16+
using Microsoft.Azure.Commands.Network.Models;
17+
using System.Management.Automation;
18+
19+
namespace Microsoft.Azure.Commands.Network
20+
{
21+
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApplicationGatewayIdentity", SupportsShouldProcess = true), OutputType(typeof(PSManagedServiceIdentity))]
22+
public class NewAzureApplicationGatewayIdentityCommand : AzureApplicationGatewayIdentityBase
23+
{
24+
public override void ExecuteCmdlet()
25+
{
26+
if (ShouldProcess("AzureApplicationGatewayIdentity", Microsoft.Azure.Commands.Network.Properties.Resources.CreatingResourceMessage))
27+
{
28+
base.ExecuteCmdlet();
29+
WriteObject(this.NewObject());
30+
}
31+
}
32+
}
33+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using Microsoft.Azure.Commands.Network.Models;
17+
using System.Management.Automation;
18+
19+
namespace Microsoft.Azure.Commands.Network
20+
{
21+
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApplicationGatewayIdentity", SupportsShouldProcess = true), OutputType(typeof(PSApplicationGateway))]
22+
public class RemoveAzureApplicationGatewayIdentityCommand : NetworkBaseCmdlet
23+
{
24+
[Parameter(
25+
Mandatory = true,
26+
ValueFromPipeline = true,
27+
HelpMessage = "The applicationGateway")]
28+
public PSApplicationGateway ApplicationGateway { get; set; }
29+
30+
[Parameter(
31+
Mandatory = false,
32+
HelpMessage = "Do not ask for confirmation.")]
33+
public SwitchParameter Force { get; set; }
34+
35+
public override void ExecuteCmdlet()
36+
{
37+
if (this.ApplicationGateway.Identity == null)
38+
{
39+
throw new ArgumentException("Gateway doesn't have an identity assigned to it.");
40+
}
41+
42+
ConfirmAction(
43+
Force.IsPresent,
44+
"Are you sure you want to remove Identity",
45+
"Removing Identity..",
46+
ApplicationGateway.Identity.ToString(),
47+
() => RemoveIdentity());
48+
}
49+
50+
private void RemoveIdentity()
51+
{
52+
base.ExecuteCmdlet();
53+
this.ApplicationGateway.Identity = null;
54+
WriteObject(this.ApplicationGateway);
55+
}
56+
}
57+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Collections.Generic;
16+
using System.Management.Automation;
17+
using Microsoft.Azure.Commands.Network.Models;
18+
19+
namespace Microsoft.Azure.Commands.Network
20+
{
21+
[Cmdlet("Set", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApplicationGatewayIdentity", SupportsShouldProcess = true), OutputType(typeof(PSApplicationGateway))]
22+
public class SetAzureApplicationGatewayIdentityCommand : AzureApplicationGatewayIdentityBase
23+
{
24+
[Parameter(
25+
Mandatory = true,
26+
ValueFromPipeline = true,
27+
HelpMessage = "The applicationGateway")]
28+
public PSApplicationGateway ApplicationGateway { get; set; }
29+
public override void ExecuteCmdlet()
30+
{
31+
if (ShouldProcess("AzureApplicationGatewayIdentity", Microsoft.Azure.Commands.Network.Properties.Resources.CreatingResourceMessage))
32+
{
33+
base.ExecuteCmdlet();
34+
this.ApplicationGateway.Identity = this.NewObject();
35+
WriteObject(this.ApplicationGateway);
36+
}
37+
}
38+
}
39+
}

src/Network/Network/ApplicationGateway/NewAzureApplicationGatewayCommand.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ public class NewAzureApplicationGatewayCommand : ApplicationGatewayBaseCmdlet
190190
[Alias("UserAssignedIdentity")]
191191
public string UserAssignedIdentityId { get; set; }
192192

193+
[Parameter(
194+
Mandatory = false,
195+
ValueFromPipelineByPropertyName = true,
196+
HelpMessage = "Application Gateway Identity to be assigned to Application Gateway.")]
197+
[ValidateNotNullOrEmpty]
198+
public PSManagedServiceIdentity Identity { get; set; }
199+
193200
[Parameter(
194201
Mandatory = false,
195202
HelpMessage = "Do not ask for confirmation if you want to overwrite a resource")]
@@ -340,6 +347,10 @@ private PSApplicationGateway CreateApplicationGateway()
340347
}
341348
};
342349
}
350+
else if (this.Identity != null)
351+
{
352+
applicationGateway.Identity = this.Identity;
353+
}
343354

344355
if (this.CustomErrorConfiguration != null)
345356
{

src/Network/Network/Az.Network.psd1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
114114
'New-AzApplicationGatewayFrontendPort',
115115
'Remove-AzApplicationGatewayFrontendPort',
116116
'Set-AzApplicationGatewayFrontendPort',
117+
'Get-AzApplicationGatewayIdentity',
118+
'New-AzApplicationGatewayIdentity',
119+
'Remove-AzApplicationGatewayIdentity',
120+
'Set-AzApplicationGatewayIdentity',
117121
'Add-AzApplicationGatewayIPConfiguration',
118122
'Get-AzApplicationGatewayIPConfiguration',
119123
'New-AzApplicationGatewayIPConfiguration',

src/Network/Network/Models/PSApplicationGateway.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,17 @@ public string UrlPathMapsText
149149
{
150150
get { return JsonConvert.SerializeObject(UrlPathMaps, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
151151
}
152+
153+
[JsonIgnore]
154+
public string IdentityText
155+
{
156+
get { return JsonConvert.SerializeObject(Identity, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
157+
}
158+
159+
[JsonIgnore]
160+
public string SslPolicyText
161+
{
162+
get { return JsonConvert.SerializeObject(SslPolicy, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
163+
}
152164
}
153165
}

0 commit comments

Comments
 (0)