This project is a Laravel package that allows you to connect to Azure Data Explorer and execute queries from your Laravel Application.
⚠️ Experimental: This package is still in development and is not ready for production use. Breaking changes can still occur without a major version change until 1.0.0.
This package is a direct extension of the Azure Data Explorer SDK for PHP by Reed Tech which provides a PHP SDK to interact with the Azure Data Explorer REST API.
The goal of this project is to provide a Laravel friendly interface to the Azure Data Explorer SDK package.
Feature Roadmap
- Caching via Redis
You can install the package via composer:
composer require reedtechus/azure-data-explorer-laravel
The following environment variables are required for this package to work:
# Azure Data Explorer
AZURE_DATA_EXPLORER_TENANT_ID="TENANT_ID"
AZURE_DATA_EXPLORER_CLIENT_ID="CLIENT_ID"
AZURE_DATA_EXPLORER_CLIENT_SECRET="SECRET"
AZURE_DATA_EXPLORER_CLUSTER="CLUSTER"
AZURE_DATA_EXPLORER_REGION="REGION"
AZURE_DATA_EXPLORER_DATABASE="DATABASE_NAME"
You can publish the config file with:
php artisan vendor:publish --tag="azure-data-explorer-laravel-config"
This is the contents of the published config file:
return [
/*
|--------------------------------------------------------------------------
| Azure Data Explorer
|--------------------------------------------------------------------------
|
| This is the configuration for the Azure Data Explorer package.
|
*/
// The base URL of the Azure Data Explorer API.
'base_url' => env('AZURE_DATA_EXPLORER_BASE_URL', 'https://login.microsoftonline.com'),
// The tenant ID of the Azure Data Explorer API.
'tenant_id' => env('AZURE_DATA_EXPLORER_TENANT_ID'),
// The client ID of the Azure Data Explorer API.
'client_id' => env('AZURE_DATA_EXPLORER_CLIENT_ID'),
// The client secret of the Azure Data Explorer API.
'client_secret' => env('AZURE_DATA_EXPLORER_CLIENT_SECRET'),
// The cache driver to use for caching responses.
'cache_driver' => env('AZURE_DATA_EXPLORER_CACHE_DRIVER', 'redis'),
// The cache TTL to use for caching responses.
'cache_ttl' => env('AZURE_DATA_EXPLORER_CACHE_TTL', 3500),
// The cluster of the Azure Data Explorer API.
'cluster' => env('AZURE_DATA_EXPLORER_CLUSTER'),
// The region of the Azure Data Explorer API.
'region' => env('AZURE_DATA_EXPLORER_REGION'),
// The database of the Azure Data Explorer API.
'database' => env('AZURE_DATA_EXPLORER_DATABASE'),
];
// Option A: More efficient to save and re-use the AzureDataExplorer class instance for followup queries
$de = new AzureDataExplorer();
$results = $de->query($query);
// Option B: you can use the AzureDataExplorer::queryOnce() method to perform the query
$results = AzureDataExplorer::queryOnce($query);
These calls return a QueryResultsDTO
object (or throw an exception).
Using the results
dump('Columns: '.implode(', ', $results->columns));
dump('Number of Results: '.count($results->data));
dump('Execution Time: '.$results->executionTime);
dump('First Row: '.print_r($results->data[0], true));
composer test
Please see CHANGELOG for more information on what has changed recently.
Please review our security policy on how to report security vulnerabilities.
This package is not endorsed nor supported by Microsoft in any way.
The MIT License (MIT). Please see License File for more information.