Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Azure API权限修复程序_Python_Azure_Azure Sdk_Azure Sdk Python - Fatal编程技术网

Python Azure API权限修复程序

Python Azure API权限修复程序,python,azure,azure-sdk,azure-sdk-python,Python,Azure,Azure Sdk,Azure Sdk Python,尝试通过azure python sdk创建安全组时,我遇到以下权限问题:msrest.exceptions.ValidationError:参数'SecurityRule.access'不能为空。我应该如何通过azure web控制台解决此权限问题?据我了解,您希望使用python sdk创建Azure网络安全组。您可以使用以下脚本: from azure.common.credentials import ServicePrincipalCredentials from az

尝试通过azure python sdk创建安全组时,我遇到以下权限问题:
msrest.exceptions.ValidationError:参数'SecurityRule.access'不能为空。
我应该如何通过azure web控制台解决此权限问题?

据我了解,您希望使用python sdk创建Azure网络安全组。您可以使用以下脚本:

    from azure.common.credentials import ServicePrincipalCredentials
    from azure.mgmt.compute import ComputeManagementClient
    from azure.mgmt.network import NetworkManagementClient
    from azure.mgmt.network.v2017_03_01.models import NetworkSecurityGroup
    from azure.mgmt.network.v2017_03_01.models import SecurityRule
    from azure.mgmt.resource.resources import ResourceManagementClient

    subscription_id = 'xxxxxxxxx-xxxxxxxxxxxxxxxxxxxx'
    credentials = ServicePrincipalCredentials(
        client_id = 'xxxxxx-xxxx-xxx-xxxx-xxxxxxx',
        secret = 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx',
        tenant = 'xxxxxx-xxxxxxx'
    )

    network_client = NetworkManagementClient(
        credentials,
        subscription_id
    )

    resource_client = ResourceManagementClient(
        credentials,
        subscription_id
    )

    resource_client.providers.register('Microsoft.Network')

    resource_group_name = 'test-rg'


    async_security_rule = network_client.security_rules.create_or_update(
    resource_group_name,
    security_group_name,
    new_security_rule_name,
    {
            'access':azure.mgmt.network.v2017_03_01.models.SecurityRuleAccess.allow,
            'description':'New Test security rule',
            'destination_address_prefix':'*',
            'destination_port_range':'123-3500',
            'direction':azure.mgmt.network.v2017_03_01.models.SecurityRuleDirection.inbound,
            'priority':400,
            'protocol':azure.mgmt.network.v2017_03_01.models.SecurityRuleProtocol.tcp,
            'source_address_prefix':'*',
            'source_port_range':'655',
    }
)

security_rule = async_security_rule.result()
有关更多详细信息,请参阅