App Configuration Client failure

Nadia Kim - Vendor 41 Reputation points
2021-05-03T17:07:03.663+00:00

Good morning team, I have a question regarding app configuration client. In what cases can app configuration fail and if does fail does it give any error? For example if the connection string is wrong?

And the second question: Can I do something like that?

let client:
if (primaryEndpoint || secondaryEndpoint) {
try {
client = new appConfig.AppConfigurationClient(primaryEndpoint);
} catch (e) {
client = new appConfig.AppConfigurationClient(secondaryEndpoint);
}
} else {
client = new appConfig.AppConfigurationClient(options.endpoints.endpoint);
}

We have region specific endpoints, wanted to make sure I can do that. Thank you

Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
200 questions
0 comments No comments
{count} votes

Accepted answer
  1. Samara Soucy - MSFT 5,046 Reputation points
    2021-05-05T00:50:56.267+00:00

    This depends on which SDK you are using. From the code you posted, I'm guessing you are using the javascript SDK and I'll answer according to that. Please correct me if this is wrong. There is some information on how to correctly setup resiliency using multiple stores, though the examples are for .NET: https://learn.microsoft.com/en-us/azure/azure-app-configuration/concept-disaster-recovery?tabs=core3x

    In the JS library creating the client only creates the object, it does not attempt to connect to the App Config instance. You will not know if a connection was successful until you try to retrieve data. This is a departure from the .NET SDK, which is usually setup to load all values into the environment variables as part of startup. You could do something similar in your JS application. If you use it as-is with values retrieved on demand, you could create a wrapper that implements the failover at the time you retrieve the value. That would also give you a place if you wanted to implement some form of value caching- instead of loading all values at startup, cache them in memory when each is retrieved so you still only have to request the value from the store once instead of every time they are used.

    The most common reason for a failed connection during initial setup is misconfigured authentication. After that is working, network issues between your application and Azure could cause the connection to fail. The third reason I can think of is an outage within Azure itself. Having the secondary endpoint pointed at a different Azure region won't cover 100% of possible scenarios, but it will greatly reduce the chance of connection failure for both stores. To cover the case of a significant outage that prevents connections to both stores, a final fallback might be to keep something in the environment variables that can keep your application running until you are able to connect to one of the regions.


0 additional answers

Sort by: Most helpful