【问题标题】:Azure API Permission FixAzure API 权限修复
【发布时间】:2019-11-07 16:38:06
【问题描述】:

当尝试通过 azure python sdk 创建安全组时,我遇到了这个权限问题:msrest.exceptions.ValidationError: Parameter 'SecurityRule.access' can not be None.我应该如何通过 azure web 控制台解决这个权限问题?

【问题讨论】:

    标签: python azure azure-sdk azure-sdk-python


    【解决方案1】:

    据我了解,您想使用 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()
    

    更多详情请参考link

    【讨论】:

      猜你喜欢
      • 2020-10-22
      • 1970-01-01
      • 1970-01-01
      • 2011-11-15
      • 2020-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多