User Profile
joruales
Joined 7 years ago
User Widgets
Recent Discussions
How to programmatically generate a link to open an App Insights KQL query?
In the App Insights UI, I can generate a link to a query by clicking on Copy -> Copy Link to Query. Is there some way to generate such a URL programmatically, If I know the query text and the App Insights endpoint?Solved11KViews1like12CommentsRe: How to programmatically generate a link to open an App Insights KQL query?
krishnachandar I'm not sure about how to do it in JS, but this is how I do it in C#: The trick is utf8-encode the query, then gzip it, then base64-encode it, then url-encode it, and finally include it in the url. static private string EncodedQuery(string query) { var bytes = Encoding.UTF8.GetBytes(query); using (MemoryStream memoryStream = ExtendedStream.CreateMemoryStream()) { using (GZipStream compressionStream = new GZipStream(memoryStream, CompressionMode.Compress, leaveOpen: true)) { compressionStream.Write(bytes, 0, bytes.Length); } memoryStream.Seek(0, SeekOrigin.Begin); Byte[] data = memoryStream.ToArray(); string encodedQuery = Convert.ToBase64String(data); return HttpUtility.UrlEncode(encodedQuery); } }10KViews1like1CommentRe: How to programmatically generate a link to open an App Insights KQL query?
Dave Rendón we have a tool that runs queries on App Insights DBs, and we would like to allow users to continue investigating by providing them a link that opens a starter query directly in app insights. I don't think that Azure Monitor workbooks fits this use case since we're not interested in a dashboard UI11KViews0likes10Comments
Recent Blog Articles
No content to show