.. versionadded:: 2015.8.0

    Regenerate storage account keys. Requires a key_type ("primary" or
    "secondary") to be specified.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f regenerate_storage_keys my-azure name=my_storage key_type=primary

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

    Regenerate storage account keys. Requires a key_type ("primary" or
    "secondary") to be specified.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f regenerate_storage_keys my-azure name=my_storage key_type=primary
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The show_storage function must be called with -f or --function.'
        )

    if not conn:
        conn = get_conn()

    if kwargs is None:
        kwargs = {}

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

    if 'key_type' not in kwargs or kwargs['key_type'] not in ('primary', 'secondary'):
        raise SaltCloudSystemExit('A key_type must be specified ("primary" or "secondary")')

    try:
        data = conn.regenerate_storage_account_keys(
            service_name=kwargs['name'],
            key_type=kwargs['key_type'],
        )
        return show_storage_keys(kwargs={'name': kwargs['name']}, call='function')
    except AzureConflictHttpError:
        raise SaltCloudSystemExit('There was a conflict. This usually means that the storage account already exists.')