wpquestionz
wpquestionz

Reputation: 149

What Can Access "App Settings Key Values"?

In an Microsoft Azure Web App Service under Application Settings, there are Key-Value pair options within the option App Settings. If a developer has PHP or Python files in multiple directories, which of these directories and (or) files would have access to these key-value pairs.

Example:

Suppose the developer has the following key value pair settings in App Settings:

Key: $variableString | Value: "My first example string."

Key: $variableNumber | Value: 1000

PHP files:

site\wwwroot\index.php

site\wwwroot\folderone\pageone.php

site\wwwroot\folderone\pagetwo.php

site\wwwroot\foldertwo\page.php

Would all these files have access to these variables, or would these files need to have a reference (and where?) to where these key-value pairs would be saved like in each PHP file with an include pointer to the App Settings file (Azure doesn't show this becomes a file)?

Thanks.

Upvotes: 0

Views: 811

Answers (2)

juunas
juunas

Reputation: 58723

They will be available as environment variables so it doesn't matter where the file is.

If you set an app setting with key ITEM_COUNT and value 15, you could use:

$item_count = getenv('ITEM_COUNT');

Or:

$item_count = getenv('APPSETTING_ITEM_COUNT');

And $item_count would contain the string "15".

Upvotes: 3

4c74356b41
4c74356b41

Reputation: 72151

Anything that can access environment variables can access those, as those are environment variables. So python would be able, not sure about php, since I know nothing about it, but pretty sure it could.

In my code I just use this:

"{0}-{1}".format(os.getenv('LOCATION'), os.getenv('COMPUTERNAME'))

Upvotes: 2

Related Questions