turbot/azure_insights

Query: key_vault_keys_for_sql_server

Usage

powerpipe query azure_insights.query.key_vault_keys_for_sql_server

SQL

with attached_keys as (
select
split_part(ep ->> 'serverKeyName','_',1) as key_vault_name,
split_part(ep ->> 'serverKeyName','_',2) as key_vault_key_name
from
azure_sql_server,
jsonb_array_elements(encryption_protector) as ep
where
lower(id) = $1
and subscription_id = split_part($1, '/', 3)
and ep ->> 'kind' = 'azurekeyvault'
)
select
lower(b.id) as key_vault_key_id
from
attached_keys as a
left join azure_key_vault_key as b on lower(a.key_vault_key_name) = lower(b.name);