{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/azure-sdk-for-python/issues/788","repository_url":"https://api.github.com/repos/Azure/azure-sdk-for-python","labels_url":"https://api.github.com/repos/Azure/azure-sdk-for-python/issues/788/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-sdk-for-python/issues/788/comments","events_url":"https://api.github.com/repos/Azure/azure-sdk-for-python/issues/788/events","html_url":"https://github.com/Azure/azure-sdk-for-python/issues/788","id":177815854,"number":788,"title":"Getting cannot parse the request exceptions when trying to create an NSG","user":{"login":"piter50","id":7049942,"avatar_url":"https://avatars.githubusercontent.com/u/7049942?v=3","gravatar_id":"","url":"https://api.github.com/users/piter50","html_url":"https://github.com/piter50","followers_url":"https://api.github.com/users/piter50/followers","following_url":"https://api.github.com/users/piter50/following{/other_user}","gists_url":"https://api.github.com/users/piter50/gists{/gist_id}","starred_url":"https://api.github.com/users/piter50/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piter50/subscriptions","organizations_url":"https://api.github.com/users/piter50/orgs","repos_url":"https://api.github.com/users/piter50/repos","events_url":"https://api.github.com/users/piter50/events{/privacy}","received_events_url":"https://api.github.com/users/piter50/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Azure/azure-sdk-for-python/labels/ARM","name":"ARM","color":"0e8a16"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-09-19T15:25:05Z","updated_at":"2016-09-20T19:09:19Z","closed_at":null,"body":"I have been trying to create an NSG with the API, but for some reason, I am getting the CloudError: cannot parse the request.\r\n\r\nI have a function to read and display existing NSGs in the subscription which works fine so I know it's not an authentication issue.\r\nMy API user has the Network Contributor role, but I also tested with it as owner so I don't think it's a permissions issue.\r\n\r\nFirst i set up some security rules and append them to a list:\r\n```\r\ndef security_rule_creation(security_list, name, source_subnet, destination_subnet, protocol,          \r\n                           direction, ports, action, priority):\r\n    security_rule = SecurityRule(\r\n        protocol=protocol,\r\n        source_address_prefix=source_subnet,\r\n        destination_address_prefix=destination_subnet, access=action, \r\n        direction=direction, id=name,\r\n        destination_port_range=ports, \r\n        source_port_range=\"*\",\r\n        priority=priority)\r\n    security_list.append(security_rule)\r\n    return\r\n```\r\n\r\nThe subnets used whilst i test are just CIDR notated strings like \"10.10.10.0/24\".  \r\nA security rule example looks like\r\n```\r\n    security_rule_creation(security_list, \"Allow-subnet-Out\", source_subnet, \r\n                          destination_subnet, \"*\", \"Outbound\", \"*\", \"Allow\", 101)\r\n```\r\nThen I try to create the NSG:\r\n```\r\nnetwork_security_group_create(network_client, location, rg_name, sec_gr_name, security_list)\r\n\r\ndef network_security_group_create(client, location, rg, name, rules):\r\n\r\n    nsg = NetworkSecurityGroup(\r\n        location=location,\r\n        security_rules=rules,\r\n        )\r\n\r\n    try:\r\n        nsg_result = client.network_security_groups.create_or_update(\r\n            rg,\r\n            name,\r\n            nsg\r\n        )\r\n        nsg_result.wait()\r\n   except CloudError as ce:\r\n        print \"Request Body: {}\\n\".format(ce.response.request.body)\r\n        print \"Request Headers: {}\\n\".format(ce.response.request.headers)\r\n        print \"Request URL: {}\\n\".format(ce.response.request.url)\r\n        print\r\n        print \"Headers {}\".format(ce.response.headers)\r\n        print \"Reason {}\".format(ce.response.reason)\r\n        print \"URL {}\".format(ce.response.url)\r\n        print \"text {}\".format(ce.response.text)\r\n        print \"CloudError: {}\".format(ce.error)\r\n\r\n    return\r\n```\r\nI'm currently doing a try except to get a better idea of the headers which seem to look ok.\r\nThe Request body using example IPs looks like this:\r\n```\r\nRequest Body: {\"properties\": {\"securityRules\": [{\r\n    \"properties\": {\r\n        \"access\": \"Allow\",\r\n        \"priority\": 101,\r\n        \"direction\": \"Outbound\",\r\n        \"protocol\": \"*\",\r\n        \"sourceAddressPrefix\": \"10.1.2.0/24\",\r\n        \"destinationPortRange\": \"*\",\r\n        \"destinationAddressPrefix\": \"10.2.0.0/16\",\r\n        \"sourcePortRange\": \"*\"\r\n}, \"id\": \"Allow-subnet-Out\"}]}, \"location\": \"someplace\"}\r\n```\r\nThe Request URL:\r\n```\r\nRequest URL: https://management.azure.com/subscriptions/111111-1111-1111-1111-111111111111/resourceGroups/RGNAME/providers/Microsoft.Network/networkSecurityGroups/NSGName?api-version=2016-06-01\r\n```\r\n\r\nAm I doing it wrong?\r\n"},"comment":{"url":"https://api.github.com/repos/Azure/azure-sdk-for-python/issues/comments/248401558","html_url":"https://github.com/Azure/azure-sdk-for-python/issues/788#issuecomment-248401558","issue_url":"https://api.github.com/repos/Azure/azure-sdk-for-python/issues/788","id":248401558,"user":{"login":"lmazuel","id":1050156,"avatar_url":"https://avatars.githubusercontent.com/u/1050156?v=3","gravatar_id":"","url":"https://api.github.com/users/lmazuel","html_url":"https://github.com/lmazuel","followers_url":"https://api.github.com/users/lmazuel/followers","following_url":"https://api.github.com/users/lmazuel/following{/other_user}","gists_url":"https://api.github.com/users/lmazuel/gists{/gist_id}","starred_url":"https://api.github.com/users/lmazuel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmazuel/subscriptions","organizations_url":"https://api.github.com/users/lmazuel/orgs","repos_url":"https://api.github.com/users/lmazuel/repos","events_url":"https://api.github.com/users/lmazuel/events{/privacy}","received_events_url":"https://api.github.com/users/lmazuel/received_events","type":"User","site_admin":false},"created_at":"2016-09-20T19:09:19Z","updated_at":"2016-09-20T19:09:19Z","body":"The error you got is a denied from the RestAPI, so this is unlikely a Python problem, but it does not mean I can't help you to figure out the problem :)\r\nCould check here:\r\nhttps://azure.microsoft.com/documentation/articles/virtual-networks-nsg/\r\n\r\nIf you follow all instructions (naming convention, conflict, etc.). You might have just a bad error message from the RestAPI for a simple problem."}}
{"actor":{"display_login":"lmazuel"}}