Terraform: Getting the public IP of a Windows vm in Azure

This is really weird, but the example on terraform does not work, however reading: https://learn.hashicorp.com/tutorials/terraform/azure-dependency?in=terraform/azure-get-started

I can see that in this example they add a dependency like this:

data "azurerm_public_ip" "example" {
  name                = azurerm_public_ip.example.name
  resource_group_name = azurerm_windows_virtual_machine.example.resource_group_name
  depends_on          = [azurerm_windows_virtual_machine.example]
}

Doing that solves the problem and the example code now works....