Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] support for REGION_NAME env variable should be more resilient to user friendly region names #2803

Closed
bgavrilMS opened this issue Jul 30, 2021 · 5 comments · Fixed by #2914
Assignees
Labels
Milestone

Comments

@bgavrilMS
Copy link
Member

bgavrilMS commented Jul 30, 2021

msal 4.35.1

REGION_NAME env variable does not seem reliable. Azure Functions sometimes populate it with the long region name (which is unusable).

The solution is:
string region = Environment.GetEnvironmentVariable("REGION_NAME")?.Replace(" ", string.Empty).?ToLower();

@jmprieur
Copy link
Contributor

@bgavrilMS @SameerK-MSFT @pmaytak
After discussing with the Azure function PM, I learnt that this is a standard conversion, and most places in azure tools to compute the short name region by stripping out whitespace and lowercasing the string. For example, CLI, ARM template processing, etc do that

So, the data we need is there in the REGION_NAME variable. And Matthew would assert that MSAL can and should be resilient to users (reasonably) passing in the versions with whitespace.

Therefore proposing to:

  • close this issue.

  • Or repurpose it to make the detection by REGION_NAME more resilient: in RegionManager.cs l 163, something like the following?

    string region = Environment.GetEnvironmentVariable("REGION_NAME")?.Replace(" ", string.Empty).?ToLower();

cc: @trwalke, @jennyf19, @henrik-me

@jmprieur
Copy link
Contributor

Unless anybody objects proposing to move it back to the triage column
Changing the title

@jmprieur jmprieur changed the title [Bug] Remove support for REGION_NAME env variable [Bug] support for REGION_NAME env variable should be more resilient to user friendly region names Sep 23, 2021
@bgavrilMS bgavrilMS added P1 and removed In PR labels Sep 28, 2021
@bgavrilMS
Copy link
Member Author

CC @rayluo - it looks like there is a path forward for REGION_NAME

@dannybtsai
Copy link

@jmprieur, do you have an example of the REGION_NAME?

@jmprieur
Copy link
Contributor

@dannybtsai

"RegionName": "East US 2",
"RegionShortName": "eastus2"

@trwalke trwalke linked a pull request Sep 30, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants