{"id":14067667,"url":"https://github.com/cloudyr/AzureKusto","last_synced_at":"2025-07-30T02:30:59.528Z","repository":{"id":70475423,"uuid":"161263733","full_name":"cloudyr/AzureKusto","owner":"cloudyr","description":"R interface to Kusto/Azure Data Explorer. Submit issues and PRs at https://github.com/Azure/AzureKusto","archived":false,"fork":false,"pushed_at":"2023-10-13T14:29:38.000Z","size":446,"stargazers_count":18,"open_issues_count":6,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-31T02:26:09.952Z","etag":null,"topics":["azure-data-explorer","database","kusto","r"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudyr.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-11T02:12:05.000Z","updated_at":"2021-10-20T15:18:46.000Z","dependencies_parsed_at":"2024-02-19T19:16:01.260Z","dependency_job_id":"c4ed799b-d420-4d3e-8162-ddad8d51cd28","html_url":"https://github.com/cloudyr/AzureKusto","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/cloudyr/AzureKusto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyr%2FAzureKusto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyr%2FAzureKusto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyr%2FAzureKusto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyr%2FAzureKusto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudyr","download_url":"https://codeload.github.com/cloudyr/AzureKusto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyr%2FAzureKusto/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267798625,"owners_count":24145727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure-data-explorer","database","kusto","r"],"created_at":"2024-08-13T07:05:43.004Z","updated_at":"2025-07-30T02:30:59.204Z","avatar_url":"https://github.com/cloudyr.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"# AzureKusto \u003cimg src=\"man/figures/logo.png\" align=\"right\" width=150 /\u003e\n\n[![CRAN](https://www.r-pkg.org/badges/version/AzureKusto)](https://cran.r-project.org/package=AzureKusto)\n![Downloads](https://cranlogs.r-pkg.org/badges/AzureKusto)\n![R-CMD-check](https://github.com/Azure/AzureKusto/workflows/R-CMD-check/badge.svg)\n\nR interface to Kusto, also known as\n[Azure Data Explorer](https://azure.microsoft.com/en-us/products/data-explorer/),\na fast and highly scalable data exploration service.\n\n## Installation\n\nAzureKusto is available on\n[CRAN](https://cran.r-project.org/package=AzureKusto).\n\n```r\noptions(repos=\"https://cloud.r-project.org\")\ninstall.packages(\"AzureKusto\")\n```\n\nYou can install the development version from GitHub. The primary repo is\nhttps://github.com/Azure/AzureKusto; please submit issues and pull requests\nthere. AzureKusto is also mirrored at the Cloudyr organisation, at\nhttps://github.com/cloudyr/AzureKusto.\n\n```r\ndevtools::install_github(\"Azure/AzureKusto\")\n```\n\n## Example usage\n\n### Kusto endpoint interface\n\nConnect to a Kusto cluster by instantiating a `kusto_database_endpoint` object with the cluster URI and database name.\n\n```r\n\nlibrary(AzureKusto)\n\nSamples \u003c- kusto_database_endpoint(server=\"https://help.kusto.windows.net\", database=\"Samples\")\n# (New in 1.1.0) Some other ways to call this that also work:\n# Samples \u003c- kusto_database_endpoint(server=\"help\", database=\"Samples\")\n# Samples \u003c- kusto_database_endpoint(cluster=\"help\", database=\"Samples\")\n\n# No app ID supplied; using KustoClient app\n# Waiting for authentication in browser...\n# Press Esc/Ctrl + C to abort\n# VSCode WebView only supports showing local http content.\n# Opening in external browser...\n# Browsing https://login.microsoftonline.com/common/oauth2/v2.0/authorize...\n# Authentication complete.\n```\n\nNow you can issue queries to the Kusto database with `run_query` and get the\nresults back as a data.frame.\n\n```r\n\nres \u003c- run_query(Samples, \"StormEvents | summarize EventCount = count() by State | order by State asc\")\n\nhead(res)\n\n##            State EventCount\n## 1        ALABAMA       1315\n## 2         ALASKA        257\n## 3 AMERICAN SAMOA         16\n## 4        ARIZONA        340\n## 5       ARKANSAS       1028\n## 6 ATLANTIC NORTH        188\n\n```\n\n`run_query()` also supports query parameters. Pass your parameters as additional\nkeyword arguments and they will be escaped and interpolated into the query\nstring.\n\n```r\n\nres \u003c- run_query(Samples, \"MyFunction(lim)\", lim=10L)\n\n```\n\nCommand statements work much the same way, except that they do not accept parameters.\n\n```r\n\nres \u003c- run_query(Samples, \".show tables\")\n\n```\n\n### dplyr Interface\n\nThe package also implements a [dplyr](https://github.com/tidyverse/dplyr)-style\ninterface for building a query upon a `tbl_kusto` object and then running it on\nthe remote Kusto database and returning the result as a regular tibble object\nwith `collect()`.\n\n```r\n\nlibrary(dplyr)\n\nStormEvents \u003c- tbl_kusto(Samples, \"StormEvents\")\n\nq \u003c- StormEvents %\u003e%\n    group_by(State) %\u003e%\n    summarize(EventCount=n()) %\u003e%\n    arrange(State)\n\nshow_query(q)\n\n## \u003cKQL\u003e database('Samples').['StormEvents']\n## | summarize ['EventCount'] = count() by ['State']\n## | order by ['State'] asc\n\ncollect(q)\n\n## # A tibble: 67 x 2\n##    State          EventCount\n##    \u003cchr\u003e               \u003cdbl\u003e\n##  1 ALABAMA              1315\n##  2 ALASKA                257\n##  3 AMERICAN SAMOA         16\n##  4 ARIZONA               340\n##  5 ARKANSAS             1028\n##  6 ATLANTIC NORTH        188\n##  7 ATLANTIC SOUTH        193\n##  8 CALIFORNIA            898\n##  9 COLORADO             1654\n## 10 CONNECTICUT           148\n## # ... with 57 more rows\n\n```\n\n(New in 1.1.0) The `$` operator can be used to access fields in dynamic columns:\n\n```r\nq \u003c- StormEvents %\u003e%\n    slice_sample(10) %\u003e%\n    mutate(Description = as.character(StormSummary$Details$Description)) %\u003e%\n    select(EventId, Description)\n\nshow_query(q)\n\n# \u003cKQL\u003e cluster('https://help.kusto.windows.net').database('Samples').['StormEvents']\n# | sample 10\n# | extend ['Description'] = tostring(['StormSummary'] . ['Details'] . ['Description'])\n# | project ['EventId'], ['Description']\n\n# # A tibble: 10 × 2\n#    EventId Description                                                                                                                                                                                                                \n#      \u003cint\u003e \u003cchr\u003e                                                                                                                                                                                                                      \n#  1   61032 A waterspout formed in the Atlantic southeast of Melbourne Beach and briefly moved toward shore.                                                                                                                           \n#  2   60904 As much as 9 inches of rain fell in a 24-hour period across parts of coastal Volusia County.                                                                                                                               \n#  3   60913 A tornado touched down in the Town of Eustis at the northern end of West Crooked Lake. The tornado quickly intensified to EF1 strength as it moved north northwest through Eustis. The track was just under two miles long…\n#  4   64588 The county dispatch reported several trees were blown down along Quincey Batten Loop near State Road 206. The cost of tree removal was estimated.                                                                          \n#  5   68796 Numerous large trees were blown down with some down on power lines. Damage occurred in eastern Adams county.                                                                                                               \n#  6   68814 This tornado began as a small, narrow path of minor damage, including a porch being blown off a house. It reached its maximum intensity as it crossed highway 29. Here, a brick home had all of its roof structure blown o…\n#  7   68834 Several trees and power lines were blown down along Zetus Road in the Zetus Community. A few of those trees were down on a mobile home which caused significant damage.                                                    \n#  8   68846 A swath of penny to quarter sized hail fell from just east of French Camp to about 6 miles north of Weir.                                                                                                                  \n#  9   73241 The heavy rain from an active monsoonal trough that had been nearly stationary just to the south of the islands caused widespread flooding across Tutuila.  Flash Flooding was reported from the Malaeimi Valley to the Ba…\n# 10   64725 State Route 8 and Rock Run Road were flooded and impassable\n\n```\n\n`tbl_kusto` also accepts query parameters, in case the Kusto source table is a\nparameterized function:\n\n```r\n\nMyFunctionDate \u003c- tbl_kusto(Samples, \"MyFunctionDate(dt)\", dt=as.Date(\"2019-01-01\"))\n\nMyFunctionDate %\u003e%\n    select(StartTime, EndTime, EpisodeId, EventId, State) %\u003e%\n    head() %\u003e%\n    collect()\n\n## # A tibble: 6 x 5\n##   StartTime           EndTime             EpisodeId EventId State         \n##   \u003cdttm\u003e              \u003cdttm\u003e                  \u003cint\u003e   \u003cint\u003e \u003cchr\u003e         \n## 1 2007-09-29 08:11:00 2007-09-29 08:11:00     11091   61032 ATLANTIC SOUTH\n## 2 2007-09-18 20:00:00 2007-09-19 18:00:00     11074   60904 FLORIDA       \n## 3 2007-09-20 21:57:00 2007-09-20 22:05:00     11078   60913 FLORIDA       \n## 4 2007-12-30 16:00:00 2007-12-30 16:05:00     11749   64588 GEORGIA       \n## 5 2007-12-20 07:50:00 2007-12-20 07:53:00     12554   68796 MISSISSIPPI   \n## 6 2007-12-20 10:32:00 2007-12-20 10:36:00     12554   68814 MISSISSIPPI   \n\n```\n\n### Exporting to storage\n\n(New in 1.1.0) The function `export()` enables you to export a query result to\nAzure Storage in one step.\n\n```r\nexport(\n    database = Samples,\n    storage_uri = \"https://mystorage.blob.core.windows.net/StormEvents\",\n    query = \"StormEvents | summarize EventCount = count() by State | order by State\",\n    name_prefix = \"events\",\n    format = \"parquet\"\n)\n\n#                                                                                 Path NumRecords SizeInBytes\n# 1 https://mystorage.blob.core.windows.net/StormEvents/events/events_1.snappy.parquet         67        1511\n\nlibrary(dplyr)\nStormEvents \u003c- tbl_kusto(Samples, \"StormEvents\")\nq \u003c- StormEvents %\u003e%\n    group_by(State) %\u003e%\n    summarize(EventCount=n()) %\u003e%\n    arrange(State) %\u003e%\n    export(\"https://mystorage.blob.core.windows.net/StormEvents\")\n\n# # A tibble: 1 × 3\n#   Path                                                                              NumRecords SizeInBytes\n#   \u003cchr\u003e                                                                                  \u003cdbl\u003e       \u003cdbl\u003e\n# 1 https://mystorage.blob.core.windows.net/StormEvents/export/export_1.snappy.parquet        50       59284\n```\n\n### DBI interface\n\nAzureKusto implements a subset of the DBI specification for interacting with\ndatabases. It should be noted that Kusto is quite different to the SQL databases\nthat DBI targets, which affects the behaviour of certain DBI methods and renders\nother moot.\n\n\n```r\nlibrary(DBI)\n\n# connect to the server: basically a wrapper for kusto_database_endpoint()\nSamples \u003c- dbConnect(AzureKusto(),\n                     server=\"https://help.kusto.windows.net\",\n                     database=\"Samples\")\n\ndbListTables(Samples)\n\n## [1] \"StormEvents\"       \"demo_make_series1\" \"demo_series2\"     \n## [4] \"demo_series3\"      \"demo_many_series1\"\n\ndbExistsTable(Samples, \"StormEvents\")\n\n##[1] TRUE\n\ndbGetQuery(Samples, \"StormEvents | summarize ct = count()\")\n\n##      ct\n## 1 59066\n```\n\n\n## Azure Resource Manager interface\n\nOn the admin side, AzureKusto extends the framework supplied by the\n[AzureRMR](https://github.com/Azure/AzureRMR) to support Kusto. Methods are\nprovided to create and delete clusters and databases, and manage database\nprincipals.\n\n```r\n# create a new Kusto cluster\naz \u003c- AzureRMR::get_azure_login()\nku \u003c- az$\n    get_subscription(\"sub_id\")$\n    get_resource_group(\"rgname\")$\n    create_kusto_cluster(\"mykustocluster\")\n\n# create a new database\ndb1 \u003c- ku$create_database(\"database1\")\n\n# add a user\ndb1$add_principals(\"myusername\", role=\"User\", fqn=\"aaduser=username@mydomain\")\n```\n\n---\n\u003cp align=\"center\"\u003e\u003ca href=\"https://github.com/Azure/AzureR\"\u003e\u003cimg src=\"https://github.com/Azure/AzureR/raw/master/images/logo2.png\" width=800 /\u003e\u003c/a\u003e\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudyr%2FAzureKusto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudyr%2FAzureKusto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudyr%2FAzureKusto/lists"}