2024-07-04 05:40:34 发布
网友
当尝试通过azure python sdk创建安全组时,我遇到了以下权限问题:msrest.exceptions.ValidationError: Parameter 'SecurityRule.access' can not be None.我应该如何通过azure web控制台解决此权限问题
msrest.exceptions.ValidationError: Parameter 'SecurityRule.access' can not be None.
据我了解,你想用pythonsdk创建一个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
据我了解,你想用pythonsdk创建一个Azure网络安全组。可以使用以下脚本:
有关详细信息,请参阅link
相关问题 更多 >
编程相关推荐