'Creates a policy assignment by ID.
Policy assignments are inherited by child resources. For example, when
you apply a policy to a resource group that policy is assigned to all
resources in the group. When providing a scope for the assigment, use
\'/subscriptions/{subscription-id}/\' for subscriptions,
\'/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}\'
for resource groups, and
\'/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}\'
for resources.
:param policy_assignment_id: The ID of the policy assignment to
create. Use the format
\'/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}\'.
:type policy_assignment_id: str
:param parameters: Parameters for policy assignment.
:type parameters: :class:`PolicyAssignment
<azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment>`
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:rtype: :class:`PolicyAssignment
<azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment>`
:rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
if raw=true
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`'

def create_by_id(self, policy_assignment_id, parameters, custom_headers=None, raw=False, **operation_config):

    url = '/{policyAssignmentId}'
    path_format_arguments = {'policyAssignmentId': self._serialize.url('policy_assignment_id', policy_assignment_id, 'str', skip_quote=True)}
    url = self._client.format_url(url, **path_format_arguments)
    query_parameters = {}
    query_parameters['api-version'] = self._serialize.query('self.api_version', self.api_version, 'str')
    header_parameters = {}
    header_parameters['Content-Type'] = 'application/json;    charset=utf-8'
    if self.config.generate_client_request_id:
        header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
    if custom_headers:
        header_parameters.update(custom_headers)
    if (self.config.accept_language is not None):
        header_parameters['accept-language'] = self._serialize.header('self.config.accept_language', self.config.accept_language, 'str')
    body_content = self._serialize.body(parameters, 'PolicyAssignment')
    request = self._client.put(url, query_parameters)
    response = self._client.send(request, header_parameters, body_content, **operation_config)
    if (response.status_code not in [201]):
        exp = CloudError(response)
        exp.request_id = response.headers.get('x-ms-request-id')
        raise exp
    deserialized = None
    if (response.status_code == 201):
        deserialized = self._deserialize('PolicyAssignment', response)
    if raw:
        client_raw_response = ClientRawResponse(deserialized, response)
        return client_raw_response
    return deserialized
