turbot/azure_insights

Query: sql_servers_for_network_virtual_network

Usage

powerpipe query azure_insights.query.sql_servers_for_network_virtual_network

SQL

with subnet_list as (
select
lower(s ->> 'id') as subnet_id
from
azure_virtual_network as v,
jsonb_array_elements(v.subnets) as s
where
lower(v.id) = $1
and v.subscription_id = split_part($1, '/', 3)
)
select
lower(s.id) as sql_server_id
from
azure_sql_server as s,
jsonb_array_elements(s.virtual_network_rules) as rule
where
lower(rule -> 'properties' ->> 'virtualNetworkSubnetId') in (select subnet_id from subnet_list);