Backend: Azurerm with Azure Stack Hub Fails (trying to connect to core.windows.net)

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 core.windows.net 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 “core.windows.net”. I have ARM_METADATA_HOST set.

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

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.