Adding new security rule to Network Security group in Azure through Java SDK
I am trying to add a custom security rule to one of my network security groups through Java SDK API. The code I am using is below (taken from reference):
NetworkSecurityGroup nsg = azure.networkSecurityGroups().getById(nsgID);
nsg.update()
.defineRule("Custom")
.allowInbound()
.fromAnyAddress()
.fromAnyPort()
.toAnyAddress()
.toPortRange(5405)
.withProtocol(SecurityRuleProtocol.UDP)
.withDescription("Allow Custom")
.withPriority(180)
.attach()
.apply();
}
The code seems to execute fine with no errors or exceptions, but at the end of it - I am not able to see my new rule listed at all as seen from my azure console. I need some help to understand why this could be so or any pointers to debug further!
azure azure-nsg
add a comment |
I am trying to add a custom security rule to one of my network security groups through Java SDK API. The code I am using is below (taken from reference):
NetworkSecurityGroup nsg = azure.networkSecurityGroups().getById(nsgID);
nsg.update()
.defineRule("Custom")
.allowInbound()
.fromAnyAddress()
.fromAnyPort()
.toAnyAddress()
.toPortRange(5405)
.withProtocol(SecurityRuleProtocol.UDP)
.withDescription("Allow Custom")
.withPriority(180)
.attach()
.apply();
}
The code seems to execute fine with no errors or exceptions, but at the end of it - I am not able to see my new rule listed at all as seen from my azure console. I need some help to understand why this could be so or any pointers to debug further!
azure azure-nsg
You can take a look at this link.
– Charles Xu
Nov 12 '18 at 6:08
Hi - I am using the example from the same link you given.
– Prasad Nagaraj
Nov 12 '18 at 14:14
OK, it seems it would be "NetworkSecurityRule.Protocol.UDP" for the protocol. And I suggest you can show the nsg id after getting it for a check.
– Charles Xu
Nov 12 '18 at 14:53
add a comment |
I am trying to add a custom security rule to one of my network security groups through Java SDK API. The code I am using is below (taken from reference):
NetworkSecurityGroup nsg = azure.networkSecurityGroups().getById(nsgID);
nsg.update()
.defineRule("Custom")
.allowInbound()
.fromAnyAddress()
.fromAnyPort()
.toAnyAddress()
.toPortRange(5405)
.withProtocol(SecurityRuleProtocol.UDP)
.withDescription("Allow Custom")
.withPriority(180)
.attach()
.apply();
}
The code seems to execute fine with no errors or exceptions, but at the end of it - I am not able to see my new rule listed at all as seen from my azure console. I need some help to understand why this could be so or any pointers to debug further!
azure azure-nsg
I am trying to add a custom security rule to one of my network security groups through Java SDK API. The code I am using is below (taken from reference):
NetworkSecurityGroup nsg = azure.networkSecurityGroups().getById(nsgID);
nsg.update()
.defineRule("Custom")
.allowInbound()
.fromAnyAddress()
.fromAnyPort()
.toAnyAddress()
.toPortRange(5405)
.withProtocol(SecurityRuleProtocol.UDP)
.withDescription("Allow Custom")
.withPriority(180)
.attach()
.apply();
}
The code seems to execute fine with no errors or exceptions, but at the end of it - I am not able to see my new rule listed at all as seen from my azure console. I need some help to understand why this could be so or any pointers to debug further!
azure azure-nsg
azure azure-nsg
edited Nov 12 '18 at 6:17
4c74356b41
24.4k32050
24.4k32050
asked Nov 12 '18 at 4:53
Prasad Nagaraj
11
11
You can take a look at this link.
– Charles Xu
Nov 12 '18 at 6:08
Hi - I am using the example from the same link you given.
– Prasad Nagaraj
Nov 12 '18 at 14:14
OK, it seems it would be "NetworkSecurityRule.Protocol.UDP" for the protocol. And I suggest you can show the nsg id after getting it for a check.
– Charles Xu
Nov 12 '18 at 14:53
add a comment |
You can take a look at this link.
– Charles Xu
Nov 12 '18 at 6:08
Hi - I am using the example from the same link you given.
– Prasad Nagaraj
Nov 12 '18 at 14:14
OK, it seems it would be "NetworkSecurityRule.Protocol.UDP" for the protocol. And I suggest you can show the nsg id after getting it for a check.
– Charles Xu
Nov 12 '18 at 14:53
You can take a look at this link.
– Charles Xu
Nov 12 '18 at 6:08
You can take a look at this link.
– Charles Xu
Nov 12 '18 at 6:08
Hi - I am using the example from the same link you given.
– Prasad Nagaraj
Nov 12 '18 at 14:14
Hi - I am using the example from the same link you given.
– Prasad Nagaraj
Nov 12 '18 at 14:14
OK, it seems it would be "NetworkSecurityRule.Protocol.UDP" for the protocol. And I suggest you can show the nsg id after getting it for a check.
– Charles Xu
Nov 12 '18 at 14:53
OK, it seems it would be "NetworkSecurityRule.Protocol.UDP" for the protocol. And I suggest you can show the nsg id after getting it for a check.
– Charles Xu
Nov 12 '18 at 14:53
add a comment |
1 Answer
1
active
oldest
votes
From looking on your code, the only thing I see that might be problematic is the call to toPortRange with just one parameter. Try switching to a call to toPort.
Take a look at WithDestinationPort definitions (there are 4 of them for different types) on the Azure SDK for Java site.
Hope it helps!
Hi - Sorry, that was a copy, paste mistake from my side I believe. I was indeed using toPortRange(5405,5407) in my code. Based on your suggestion, I also tried the call with toPort(5406) but no change in the result. I am not seeing that this rule is getting added.
– Prasad Nagaraj
Nov 12 '18 at 14:17
Try running the following command in powershell to check if you see the rule from there: Get-AzureRmNetworkSecurityGroup -Name [nsg-name] -ResourceGroupName [rg-name] | Get-AzureRmNetworkSecurityRuleConfig -Name [rule-name]
– Itay Podhajcer
Nov 12 '18 at 14:26
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256144%2fadding-new-security-rule-to-network-security-group-in-azure-through-java-sdk%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
From looking on your code, the only thing I see that might be problematic is the call to toPortRange with just one parameter. Try switching to a call to toPort.
Take a look at WithDestinationPort definitions (there are 4 of them for different types) on the Azure SDK for Java site.
Hope it helps!
Hi - Sorry, that was a copy, paste mistake from my side I believe. I was indeed using toPortRange(5405,5407) in my code. Based on your suggestion, I also tried the call with toPort(5406) but no change in the result. I am not seeing that this rule is getting added.
– Prasad Nagaraj
Nov 12 '18 at 14:17
Try running the following command in powershell to check if you see the rule from there: Get-AzureRmNetworkSecurityGroup -Name [nsg-name] -ResourceGroupName [rg-name] | Get-AzureRmNetworkSecurityRuleConfig -Name [rule-name]
– Itay Podhajcer
Nov 12 '18 at 14:26
add a comment |
From looking on your code, the only thing I see that might be problematic is the call to toPortRange with just one parameter. Try switching to a call to toPort.
Take a look at WithDestinationPort definitions (there are 4 of them for different types) on the Azure SDK for Java site.
Hope it helps!
Hi - Sorry, that was a copy, paste mistake from my side I believe. I was indeed using toPortRange(5405,5407) in my code. Based on your suggestion, I also tried the call with toPort(5406) but no change in the result. I am not seeing that this rule is getting added.
– Prasad Nagaraj
Nov 12 '18 at 14:17
Try running the following command in powershell to check if you see the rule from there: Get-AzureRmNetworkSecurityGroup -Name [nsg-name] -ResourceGroupName [rg-name] | Get-AzureRmNetworkSecurityRuleConfig -Name [rule-name]
– Itay Podhajcer
Nov 12 '18 at 14:26
add a comment |
From looking on your code, the only thing I see that might be problematic is the call to toPortRange with just one parameter. Try switching to a call to toPort.
Take a look at WithDestinationPort definitions (there are 4 of them for different types) on the Azure SDK for Java site.
Hope it helps!
From looking on your code, the only thing I see that might be problematic is the call to toPortRange with just one parameter. Try switching to a call to toPort.
Take a look at WithDestinationPort definitions (there are 4 of them for different types) on the Azure SDK for Java site.
Hope it helps!
answered Nov 12 '18 at 6:01
Itay Podhajcer
1,769312
1,769312
Hi - Sorry, that was a copy, paste mistake from my side I believe. I was indeed using toPortRange(5405,5407) in my code. Based on your suggestion, I also tried the call with toPort(5406) but no change in the result. I am not seeing that this rule is getting added.
– Prasad Nagaraj
Nov 12 '18 at 14:17
Try running the following command in powershell to check if you see the rule from there: Get-AzureRmNetworkSecurityGroup -Name [nsg-name] -ResourceGroupName [rg-name] | Get-AzureRmNetworkSecurityRuleConfig -Name [rule-name]
– Itay Podhajcer
Nov 12 '18 at 14:26
add a comment |
Hi - Sorry, that was a copy, paste mistake from my side I believe. I was indeed using toPortRange(5405,5407) in my code. Based on your suggestion, I also tried the call with toPort(5406) but no change in the result. I am not seeing that this rule is getting added.
– Prasad Nagaraj
Nov 12 '18 at 14:17
Try running the following command in powershell to check if you see the rule from there: Get-AzureRmNetworkSecurityGroup -Name [nsg-name] -ResourceGroupName [rg-name] | Get-AzureRmNetworkSecurityRuleConfig -Name [rule-name]
– Itay Podhajcer
Nov 12 '18 at 14:26
Hi - Sorry, that was a copy, paste mistake from my side I believe. I was indeed using toPortRange(5405,5407) in my code. Based on your suggestion, I also tried the call with toPort(5406) but no change in the result. I am not seeing that this rule is getting added.
– Prasad Nagaraj
Nov 12 '18 at 14:17
Hi - Sorry, that was a copy, paste mistake from my side I believe. I was indeed using toPortRange(5405,5407) in my code. Based on your suggestion, I also tried the call with toPort(5406) but no change in the result. I am not seeing that this rule is getting added.
– Prasad Nagaraj
Nov 12 '18 at 14:17
Try running the following command in powershell to check if you see the rule from there: Get-AzureRmNetworkSecurityGroup -Name [nsg-name] -ResourceGroupName [rg-name] | Get-AzureRmNetworkSecurityRuleConfig -Name [rule-name]
– Itay Podhajcer
Nov 12 '18 at 14:26
Try running the following command in powershell to check if you see the rule from there: Get-AzureRmNetworkSecurityGroup -Name [nsg-name] -ResourceGroupName [rg-name] | Get-AzureRmNetworkSecurityRuleConfig -Name [rule-name]
– Itay Podhajcer
Nov 12 '18 at 14:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256144%2fadding-new-security-rule-to-network-security-group-in-azure-through-java-sdk%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You can take a look at this link.
– Charles Xu
Nov 12 '18 at 6:08
Hi - I am using the example from the same link you given.
– Prasad Nagaraj
Nov 12 '18 at 14:14
OK, it seems it would be "NetworkSecurityRule.Protocol.UDP" for the protocol. And I suggest you can show the nsg id after getting it for a check.
– Charles Xu
Nov 12 '18 at 14:53