def policy_assignment_create(name, scope, definition_name, **kwargs):
    '''
    .. versionadded:: 2019.2.0

    Create a policy assignment.

    :param name: The name of the policy assignment to create.

    :param scope: The scope of the policy assignment.

    :param definition_name: The name of the policy definition to assign.

    CLI Example:

    .. code-block:: bash

        salt-call azurearm_resource.policy_assignment_create testassign \
        /subscriptions/bc75htn-a0fhsi-349b-56gh-4fghti-f84852 testpolicy

    '''
    polconn = __utils__['azurearm.get_client']('policy', **kwargs)

    # "get" doesn't work for built-in policies per https://github.com/Azure/azure-cli/issues/692
    # Uncomment this section when the ticket above is resolved.
    #  BEGIN
    # definition = policy_definition_get(
    #     name=definition_name,
    #     **kwargs
    # )
    #  END

    # Delete this section when the ticket above is resolved.
    #  BEGIN
    definition_list = policy_definitions_list(
        **kwargs
    )
    if definition_name in definition_list:
        definition = definition_list[definition_name]
    else:
        definition = {'error': 'The policy definition named "{0}" could not be found.'.format(definition_name)}
    #  END

    if 'error' not in definition:
        definition_id = str(definition['id'])

        prop_kwargs = {'policy_definition_id': definition_id}

        policy_kwargs = kwargs.copy()
        policy_kwargs.update(prop_kwargs)

        try:
            policy_model = __utils__['azurearm.create_object_model'](
                'resource.policy',
                'PolicyAssignment',
                **policy_kwargs
            )
        except TypeError as exc:
            result = {'error': 'The object model could not be built. ({0})'.format(str(exc))}
            return result

        try:
            policy = polconn.policy_assignments.create(
                scope=scope,
                policy_assignment_name=name,
                parameters=policy_model
            )
            result = policy.as_dict()
        except CloudError as exc:
            __utils__['azurearm.log_cloud_error']('resource', str(exc), **kwargs)
            result = {'error': str(exc)}
        except SerializationError as exc:
            result = {'error': 'The object model could not be parsed. ({0})'.format(str(exc))}
    else:
        result = {'error': 'The policy definition named "{0}" could not be found.'.format(definition_name)}

    return result
def policy_assignment_create ( name , scope , definition_name , ** kwargs ) : polconn = __utils__ [ 'azurearm.get_client' ] ( 'policy' , ** kwargs ) definition_list = policy_definitions_list ( ** kwargs ) if definition_name in definition_list : definition = definition_list [ definition_name ] else : definition = { 'error' : 'The policy definition named "{0}" could not be found.' . format ( definition_name ) } if 'error' not in definition : definition_id = str ( definition [ 'id' ] ) prop_kwargs = { 'policy_definition_id' : definition_id } policy_kwargs = kwargs . copy ( ) policy_kwargs . update ( prop_kwargs ) try : policy_model = __utils__ [ 'azurearm.create_object_model' ] ( 'resource.policy' , 'PolicyAssignment' , ** policy_kwargs ) except TypeError as exc : result = { 'error' : 'The object model could not be built. ({0})' . format ( str ( exc ) ) } return result try : policy = polconn . policy_assignments . create ( scope = scope , policy_assignment_name = name , parameters = policy_model ) result = policy . as_dict ( ) except CloudError as exc : __utils__ [ 'azurearm.log_cloud_error' ] ( 'resource' , str ( exc ) , ** kwargs ) result = { 'error' : str ( exc ) } except SerializationError as exc : result = { 'error' : 'The object model could not be parsed. ({0})' . format ( str ( exc ) ) } else : result = { 'error' : 'The policy definition named "{0}" could not be found.' . format ( definition_name ) } return result
.. versionadded:: 2019.2.0

    Create a policy assignment.

    :param name: The name of the policy assignment to create.

    :param scope: The scope of the policy assignment.

    :param definition_name: The name of the policy definition to assign.

    CLI Example:

    .. code-block:: bash

        salt-call azurearm_resource.policy_assignment_create testassign \
        /subscriptions/bc75htn-a0fhsi-349b-56gh-4fghti-f84852 testpolicy