Terraform plan fails on remote backend

hi,

I am facing issue whlist running terraform plan on azure account with Service Principal. The terraform backend is initialised properly. But the terraform plan fails.

I first faced the error on my corporate development subscription and reproduced the error on my personal subscription.

I validated the terraform code through Azure Cloud Shell. Just exported the ARM* variables and ran terraform plan and it worked.

I am running terraform on Ubuntu WSL 2202.

plan.error.log.txt (1.6 MB)

nishad@XXXX-XXXX:/c/code/terraform-azure-demo$ terraform init

Initializing the backend...

Successfully configured the backend "azurerm"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Finding hashicorp/azurerm versions matching "~> 3.26.0"...
- Installing hashicorp/azurerm v3.26.0...
- Installed hashicorp/azurerm v3.26.0 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
nishad@XXXX-XXXX:/c/code/terraform-azure-demo$ terraform plan
╷
│ Error: building account: getting authenticated object ID: building oauthConfig: parse "087ff792-fdd5-46eb-8d13-8db714aef426\r": net/url: invalid control character in URL
│
│   with provider["registry.terraform.io/hashicorp/azurerm"],
│   on backend.tf line 18, in provider "azurerm":
│   18: provider "azurerm" {
│
╵
nishad@XXXX-XXXX:/c/code/terraform-azure-demo$ cat /etc/resolv.conf
$ terraform version
Terraform v1.3.2
on linux_amd64
+ provider registry.terraform.io/hashicorp/azurerm v3.26.0
 env | grep ^ARM
ARM_CLIENT_ID=<Redact>
ARM_TENANT_ID=<Redact>
ARM_CLIENT_SECRET=<Redact>
ARM_SUBSCRIPTION_ID=<Redact>
ARM_ACCESS_KEY=<Redact>
backend.tf
terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~>3.26.0"
    }
  }

  backend "azurerm" {
    resource_group_name  = "rg_data_0"
    storage_account_name = "myterraformstate0"
    container_name       = "tfstate"
    key                  = "terraform.tfstate"
  }

}

provider "azurerm" {
  features {}
}

Hi, A quick update. This works on windows, but i really need it to work on bash.

PS C:\code\terraform-azure-demo> terraform plan

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
  + create

Terraform will perform the following actions:

  # azurerm_resource_group.rg_sample will be created
  + resource "azurerm_resource_group" "rg_sample" {
      + id       = (known after apply)
      + location = "australiaeast"
      + name     = "rg-sample"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run
"terraform apply" now.
PS C:\code\terraform-azure-demo>