-
Notifications
You must be signed in to change notification settings - Fork 0
GetConfigurationMethod
The azure-config-util object instance presents a config() method that returns a promise, that will resolve to a cached configuration object.
This configuration comes with an Configuration Table (Azure Storage Table) whose name/configuration is passed into function that creates the instance (or via Environment Variables)
The resulting configuration lookup is the core to all other extension methods on an instance.
// ES7 async/await
var cfg = await azureUtil.config();// Promise/Thenable
azureUtil.config().then(function(cfg){
...
});The Namespace field represents the namespace of the application itself. All results subject to a given configuration object will be within the same namespace.
The environment field represents one of the following runtime environments, or the hostname of a machine for configuration values.
When a given environment is selected, a set of values for Environment are queried and the most relevant response is returned, as follows. hostname refers to the given hostname for the runtime environment (require('os').hostname()), other values are literal strings.
-
local(default)- priority: [
hostname,local,development,dev,default]
- priority: [
-
developmentordev- priority: [
hostname,development,dev,default]
- priority: [
-
testingortest- priority: [
hostname,testing,test,default]
- priority: [
-
qa- priority: [
hostname,qa,default]
- priority: [
-
stagingorstage- priority: [
hostname,staging,stage,default]
- priority: [
-
productionorprod- priority: [
hostname,production,prod,default]
- priority: [
The Section field represents a collection of configuration keys, and is a hierarchal structure/value. In the configuration object, this value is lowercased, and trimmed for easier lookup.
The Key field represents a single value under a Section. The value is deconstructed from the JsonValue field.
For example, you have the following records
| Namespace | Environment | Section | Key | JsonValue |
|---|---|---|---|---|
| default | development | table | mytable | {"storage":"mytest"} |
| default | mydesktop | table | mytable | {"storage":"mydev"} |
When running this example from a host with a name of "mydesktop" you will get an object with the following structure.
expect(cfg).to.deep.equal({
"table": {
"mytable": {
"storage": "mytest"
}
}
}); //trueWhen running under a CONFIG_ENV or NODE_ENV of either "dev" or "development" from another hostname, you'll get the reflected value in the configuration.