Backend: Azurerm with Azure Stack Hub Fails (trying to connect to

I am trying to use azurerm in a backend block with Azure Stack Hub and azurerm provider is failing to connect to my local Azure Stack Hub container. The provider does recognize my storage account name however it adds to every URL and I have a different on-premises URL.

I looked at the Azurerm backend provider documentation. I do not see a way to override the “”. I have ARM_METADATA_HOST set.

This looks very similar to this problem:
Hardcoded makes azurerm not work in China (proably Germany and Government environments too) · Issue #11136 · hashicorp/terraform (

Need to set the environment = “AzureStack-User-<GUID>”. This is obtainable from the metadata query URL.

Also, set metadata_host to the actual management.<localURL> and do not add https or http.

Finally, I got it working with just a SAS token.