I created a new cluster in Azure and using python api, I want to create a database and tables inside it. However, it gives me error that my cluster endpoint does not exists.
Error: The requested endpoint 'https://<clustername>/v1/rest/mgmt' does not exist
My code:
client_id = <client-id>
client_secret = <client_secret>
AAD_TENANT_ID = <AAD_TENANT_ID>
query = .create table Raw_production_replicaatenant_785(TimeStamp:datetime,ID:int,StatusCode:dynamic,R1:real)
def Kusto_Execute(db,query):
cluster = "https://<cluster-name>/"
kcsb = KustoConnectionStringBuilder.with_aad_application_key_authentication(cluster, client_id, client_secret, AAD_TENANT_ID)
client = KustoClient(kcsb)
response = client.execute(db, query)
Can anyone identity the issue? For clarity, my api is using active directory authentication method to authenticate with azure cluster and I have have admin rights to this app on my cluster as well.
More information: the same code works for my other azure cluster. The error is occurring on new cluster. Do I need a new aad app registered for it?
Any feedback would be helpful. Thanks
I tried in my environment and got the below results:
Initially, I got the same error in my environment:
azure.kusto.data.exceptions.KustoServiceError:The requested endpoint 'https://<cluster name.location.kusto.window.net/v1/rest/mgmt' does not exist
The above error occurs when you pass the wrong database name in the code.
After I tried with the correct database with the below code it executed successfully.
Code:
from azure.kusto.data import KustoClient, KustoConnectionStringBuilder
from azure.kusto.data.helpers import dataframe_from_result_table
client_id = "Client_id"
client_secret ="Client_secret"
AAD_TENANT_ID = "Tenant_id"
def Kusto_Execute():
cluster = "https://<your clustername>.location.kusto.windows.net"
query = ".create table Raw_production_replicaatenant_785(TimeStamp:datetime,ID:int,StatusCode:dynamic,R1:real)"
db="<your database name>"
kcsb = KustoConnectionStringBuilder.with_aad_application_key_authentication(cluster, client_id, client_secret, AAD_TENANT_ID)
client = KustoClient(kcsb)
response = client.execute(db,query)
df = dataframe_from_result_table(response.primary_results[0])
print(df)
Kusto_Execute()
Output:
Reference: Query data using the Azure Data Explorer Python library | Microsoft Learn