Question

A bad Azure connection string will hang my application indefinitely the first time I contact azure; in my case during blobContainer.CreateIfNotExist();.

Other SO posts about connectivity checking mentioned setting timeouts, but it still hangs indefinitely with a 2s timeout: blobContainer.CreateIfNotExist(new BlobRequestOptions() { Timeout = new TimeSpan(0, 0, 2) });

What's the correct way to check if an Azure connection string is valid?

Was it helpful?

Solution

I thought the default retry policy only made three attempts?

In any case, assuming the retry policy is to blame for the lengthy hang, you could probably just disable retries altogether. You'd still want to make sure you actually got a response from the server before concluding that the connection string was invalid. (A network error could cause the failure, and with retries turned off, this kind of thing is more likely.)

Code would be something like the following (completely untested, not even sure it will compile):

container.CreateIfNotExists(new BlobRequestOptions {
    RetryPolicy = RetryPolicies.NoRetry });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top