unable to create NetworkSecurityGroup using api
See original GitHub issuecode sample is below:
NetworkSecurityGroup nsg = new NetworkSecurityGroup();
nsg.setName("testnsg");
nsg.setLocation(context.getLocation());
SecurityRule sr= new SecurityRule();
sr.setPriority(100);
sr.setProtocol("*");
sr.setSourceAddressPrefix("*");
sr.setSourcePortRange("*");
sr.setAccess("Allow");
sr.setDirection("Inbound");
sr.setDestinationAddressPrefix("*");
sr.setDestinationPortRange("*");
ArrayList<SecurityRule> srs = new ArrayList<SecurityRule>();
srs.add(sr);
nsg.setSecurityRules(srs);
networkResourceProviderClient.getNetworkSecurityGroupsOperations().createOrUpdate(resourceGroupName, nsg
.getName(), nsg);
server return PROPERTIES statusCode:BadRequest serviceRequestId:b9c90aed-1e3d-4708-ae5b-f9dc03560d62 statusMessage:{“error”:{“code”:“InvalidRequestFormat”,“message”:“Cannot parse the request.”,“details”:[]}} responseBody:{“error”:{“code”:“InvalidRequestFormat”,“message”:“Cannot parse the request.”,“details”:[]}}
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Network Security Groups - Create Or Update - Microsoft Learn
Learn more about Virtual Networks service - Creates or updates a network security group in the specified resource group.
Read more >Error codes for the Amazon EC2 API - AWS Documentation
You cannot create a security group with the same name as an existing security group in the same VPC, or the same AWS...
Read more >ansible - unable to create Azure network security group
Based on official and "latest" documentation at this URL. Notice the example, the case of the protocol is " Tcp ", not "...
Read more >Allow Only Administrators to Create Security Groups
Ensure that "Users can create security groups in Azure portals" is set to "No" within your Azure Active Directory settings in order to...
Read more >How to create network security groups (NSGs) in Azure | Aviatrix
NSGs can be associated with subnets or individual virtual machine instances within that subnet. When an NSG is associated with a subnet, the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No action to take at this moment. With 1.0.0-beta2 released, this should be simplified. A sample can be found here: https://github.com/Azure-Samples/network-java-manage-network-security-group/blob/master/src/main/java/com/microsoft/azure/management/network/samples/ManageNetworkSecurityGroup.java.
@selvasingh
A valid scenario to be added.
@jianghaolu this sample is absolutely not simplified. Think of this case: I want to write an application to deploy resources, including the network, NSG and rules contained in the NSG. The newer syntax removes any possibility of me being able to write methods to add security rules that are not VERY strictly defined. There is no method to add ACCESS, beyond “allowInbound, denyInbound, allowOutbound, denyOutbound”. There’s no way for me to pass in the Access type without calling those methods from code… this means if I want to be able to have a rule created dynamically, I have to have every possible combination (allow inbound with all ports, allow inbound with a specific inbound port, with a specific destination port, allow inbound with a specific destination port but any source port… etc) This ends up being A VERY LARGE number of methods, with a very complicated control structure to determine which method to call. Why is there no way to create a rule, pass it a variable that is the access type, a variable that is the direction, a variable that is the source port (which must be string to allow it to be a single port, a range, or * for any), a variable that is destination port, a variable that is protocol? It appears there used to be, and now the usage is extremely broken. I’m not sure I will be able to meet my needs with this SDK now…