question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Azure Search] Support cleaning cache for Azure Search Client

See original GitHub issue

My customer wants to have a feature to clear the cache of the Azure Search.

My customer encounter the shortage of Azure Search. Azure Search had a shortage however, it successfully fail over to change the DNS. However, the client side, they cache Azure Search Client, and there is no way to clear cache. Azure Functions recommend to make Client Static. For the standard API of the Client, we can pass the HttpClientHandler instance to the client. However not for SocketsHttpHandler which support cleaning DNS cache.

We ended up with use refrection to inject the DNS cache configuration. This might be mandatory to support the fail over.

This is our current work around.

    public class KeepAliveAvailableHttpClientHandler : HttpClientHandler
    {
        private readonly FieldInfo _fieldInfo =
            typeof(HttpClientHandler).GetField("_socketsHttpHandler", BindingFlags.NonPublic | BindingFlags.Instance);

        public KeepAliveAvailableHttpClientHandler()
        {
            var socketHttpHandler = (SocketsHttpHandler) _fieldInfo.GetValue(this);
            socketHttpHandler.PooledConnectionIdleTimeout = TimeSpan.FromMinutes(3);
            socketHttpHandler.PooledConnectionLifetime = TimeSpan.FromMinutes(1);
        }

    }

pass it.

var handler = new KeepAliveAvailableHttpClientHandler();
indexClient = new SearchIndexClient(searchServiceName, "azuresql-index", new SearchCredentials(adminApiKey), handler , null);
 

For more detail, I wrote a blog about it.

https://medium.com/@tsuyoshiushio/cleaning-dns-cache-with-azure-search-client-14cbd73d8195

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
brjohnstmsftcommented, Jan 31, 2019

Adding @alexghiondea and @weshaggard since they are handling data plane-related requirements for the Azure .NET SDKs going forward.

0reactions
brjohnstmsftcommented, Feb 20, 2019

@TsuyoshiUshio I haven’t heard from you, so I’m closing this issue. Please let me know if you have a reason to re-open it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cleaning DNS cache with Azure Search Client - Tsuyoshi Ushio
Cleaning DNS cache for Azure Search SDK. However, Azure Search Client only support HttpClientHandler. We can't set the SocketHttpClient.
Read more >
Azure Cognitive Search - Cloud Search Service
Azure Cognitive Search is a fully managed cloud search service that provides a better user experience for customers. Add Cognitive Search to your...
Read more >
Run or reset indexers - Azure Cognitive Search
Run indexers in full, or reset an indexer, skills, or individual documents to refresh all or part of a search index or knowledge...
Read more >
How to work with search results - Azure Cognitive Search
Define search result composition, get a document count, sort results, and add content navigation to search results in Azure Cognitive Search.
Read more >
Security overview - Azure Cognitive Search
This article describes the security features in Azure Cognitive Search that protect data and operations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found