简体   繁体   中英

How to determine whether my Azure connection string is valid

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?

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 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM