.. versionadded:: 2015.8.0

    Delete a specific affinity group associated with the account

    CLI Examples:

    .. code-block:: bash

        salt-cloud -f delete_affinity_group my-azure name=my_affinity_group

def delete_affinity_group(kwargs=None, conn=None, call=None):
    '''
    .. versionadded:: 2015.8.0

    Delete a specific affinity group associated with the account

    CLI Examples:

    .. code-block:: bash

        salt-cloud -f delete_affinity_group my-azure name=my_affinity_group
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The delete_affinity_group function must be called with -f or --function.'
        )

    if kwargs is None:
        kwargs = {}

    if 'name' not in kwargs:
        raise SaltCloudSystemExit('A name must be specified as "name"')

    if not conn:
        conn = get_conn()

    try:
        conn.delete_affinity_group(kwargs['name'])
        return {'Success': 'The affinity group was successfully deleted'}
    except AzureMissingResourceHttpError as exc:
        raise SaltCloudSystemExit('{0}: {1}'.format(kwargs['name'], exc.message))