Using Data Source to filter out existing vnet cidr blocks

Can you use data sources to list and filter out existing address spaces or cidr blocks when creating vnets and subnets in Azure?

We are currently switching from using ansible to manage our infrastructure to using terraform. Since we are constantly needing to bring up and down environments our currently ansible code is able to calculate number the cidr block for a new environment by doing the below

  • calculating the available vnets in vnet base
    -generating all available subnets
    -listing available vnets from the subscriptions
  • filtering out the existing CIDR blocks associated with them
    -selecting a CIDR block for use on new vnet based on the above

I know it will be a different approach in terraform but I am wondering if the functionality exists. I was thinking it might be something I could do using data sources and maybe some inbuilt terraform functions