我正在尝试使用C#建立与Azure DataExplorer群集的连接。 我在https://docs.microsoft.com/en-us/azure/kusto/api/netfx/about-kusto-data中引用了C# 并在Visual Studio中安装了nuget包kusto.data,然后复制了代码,并在cmd提示符下运行了dotnet,但这没用。
下面是我的代码-
from bs4 import BeautifulSoup
import mechanize
import time
import urllib.request
import string
start = "http://www.irrelevantcheetah.com/browserimages.html"# test website
filetype = input("What file type are you looking for?\n")
br = mechanize.Browser()
r = br.open(start)
html = r.read()
soup = BeautifulSoup(html, "html5lib")
for link in soup.find_all('a'):
linkText = str(link)
fileName = str(link.get('href'))
if filetype in fileName:
image = urllib.request.URLopener()
linkGet = "http://www.irrelevantcheetah.com" + fileName
filesave = string.lstrip(fileName, '/')
image.retrieve(linkGet, filesave)
我尝试了Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("google.com"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(MyApp.getContext(), 0, intent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(MyApp.getContext(), "MyApp")
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle("my App")
.setContentText("Click here to call the URL")
.setStyle(new NotificationCompat.BigTextStyle().bigText("...."))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
;
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(MyApp.getContext());
notificationManager.notify(getNotificationId(), builder.build());
和using Microsoft.Azure.Management.Kusto;
using System;
namespace LensDashboradOptimization
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
//var clusterUrl = "https://masvaas.kusto.windows.net";
//var kcsb = new Kusto.Data.KustoConnectionStringBuilder(clusterUrl);
//Console.WriteLine(kcsb);
// Read the first row from reader -- it's 0'th column is the count of records in MyTable
// Don't forget to dispose of reader when done.
var client = Kusto.Data.Net.Client.KustoClientFactory.CreateCslQueryProvider("https://masvaas.windows.net/Samples;Fed=true");
var reader = client.ExecuteQuery("MyTable | count");
Console.WriteLine(reader);
}
}
}
都没有用。我想念什么吗?
答案 0 :(得分:0)
您好,欢迎来到Stack Overflow!
我在检查时遇到了类似的错误。但是问题出在我运行的.Net Framework版本上。 Kusto.Data程序包需要.Net Framework 4.6.2作为依赖项。安装完该软件包后,我便可以install并导入软件包,随后还可以连接到预期的Kusto群集并读取数据。这是对我有用的代码段:
using System;
using Kusto.Data;
namespace hello_world
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var client = Kusto.Data.Net.Client.KustoClientFactory.CreateCslQueryProvider("https://help.kusto.windows.net/Samples;Fed=true");
var reader = client.ExecuteQuery("StormEvents | sort by StartTime desc | take 10");
}
}
}
请仔细检查依赖性,并让我知道您是否仍然遇到问题。希望这会有所帮助!
答案 1 :(得分:0)
using Kusto.Data;
using Kusto.Data.Common;
using Kusto.Data.Net.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
只有这些using语句可以完成您要尝试的工作。为此,您需要从nuget gallery安装SDK。 另外,仅从上方安装 Microsoft.Azure.Kusto.Data 和 Microsoft.Azure.Management.Kusto 。足够了。
希望获得帮助。
您可以看到的其他内容如下:1)静态IP 2)已安装Azure开发包的VS 2019社区版
答案 2 :(得分:0)
WithAadUserPromptAuthentication,现在不支持此方法,因为kusto数据库首先需要用户身份验证。并且控制台应用程序无法打开提示窗口。我建议使用Web应用程序。