Skip to content

Commit 22c11c9

Browse files
author
Ed Munoz
committed
Add warning when association not fully created for Role and NIC
1 parent af28796 commit 22c11c9

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

src/ServiceManagement/Network/Commands.Network/NetworkSecurityGroup/Association/GetAzureNetworkSecurityGroupAssociation.cs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ public class GetAzureNetworkSecurityGroupAssociation : NetworkCmdletBase
8080
public override void ExecuteCmdlet()
8181
{
8282
NetworkSecurityGroupGetAssociationResponse assocResponse = null;
83+
string warningAssociationNotFullyCrated = null;
8384
if (string.Equals(this.ParameterSetName, GetNetworkSecurityGroupAssociationForSubnet))
8485
{
8586
assocResponse = Client.GetNetworkSecurityGroupForSubnet(VirtualNetworkName, SubnetName);
8687

87-
if (assocResponse.State != "Created")
88-
{
89-
WriteWarningWithTimestamp(
90-
string.Format(Resources.NetworkSecurityGroupNotActiveInSubnet, assocResponse.Name, VirtualNetworkName, SubnetName));
91-
92-
}
88+
warningAssociationNotFullyCrated = string.Format(
89+
Resources.NetworkSecurityGroupNotActiveInSubnet,
90+
assocResponse.Name,
91+
VirtualNetworkName,
92+
SubnetName);
9393
}
9494
else
9595
{
@@ -105,6 +105,12 @@ public override void ExecuteCmdlet()
105105
this.ServiceName,
106106
this.obtainedDeploymentName,
107107
this.RoleName);
108+
109+
warningAssociationNotFullyCrated = string.Format(
110+
Resources.NetworkSecurityGroupNotActiveInRole,
111+
this.ServiceName,
112+
this.obtainedDeploymentName,
113+
this.RoleName);
108114
}
109115
else
110116
{
@@ -113,9 +119,21 @@ public override void ExecuteCmdlet()
113119
this.obtainedDeploymentName,
114120
this.RoleName,
115121
this.NetworkInterfaceName);
122+
123+
warningAssociationNotFullyCrated = string.Format(
124+
Resources.NetworkSecurityGroupNotActiveInNIC,
125+
this.ServiceName,
126+
this.obtainedDeploymentName,
127+
this.RoleName,
128+
this.NetworkInterfaceName);
116129
}
117130
}
118131

132+
if (assocResponse.State != "Created")
133+
{
134+
WriteWarningWithTimestamp(warningAssociationNotFullyCrated);
135+
}
136+
119137
INetworkSecurityGroup securityGroup = Client.GetNetworkSecurityGroup(assocResponse.Name, Detailed);
120138
WriteObject(securityGroup);
121139
}

src/ServiceManagement/Network/Commands.Network/Properties/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServiceManagement/Network/Commands.Network/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,10 @@
294294
<data name="SetNSGSubnetAssociationTarget" xml:space="preserve">
295295
<value>Network Security Group "{0}", Virtual Network: "{1}", Subnet "{2}"</value>
296296
</data>
297+
<data name="NetworkSecurityGroupNotActiveInNIC" xml:space="preserve">
298+
<value>Network SecurityGroup "{0}" is not active in cloud service "{1}", deployment "{2}", role "{3}", network interface "{4}".</value>
299+
</data>
300+
<data name="NetworkSecurityGroupNotActiveInRole" xml:space="preserve">
301+
<value>Network SecurityGroup "{0}" is not active in cloud service "{1}", deployment "{2}", role "{3}".</value>
302+
</data>
297303
</root>

0 commit comments

Comments
 (0)