我对 Azure Application Insight 完全陌生,并尝试通过我的本地计算机发送 TrackEvent。但Azure Application Insight似乎没有收到任何信息。
这是我的要求。规格 我安装了 application Insight sdk nuget 的示例 asp.net 框架控制台代码是使用遥测客户端和配置的 Instrumental Id 进行设置的。控制台运行后,Azure 应用程序洞察应按预期显示历史记录。但它没有显示任何东西。我错过了什么吗?
我的简单控制台代码
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey = "c453fec7-ea68-4c06-83e4-2938eef1f124";
TelemetryClient telemetry = new TelemetryClient();
telemetry.Context.User.Id = "Test User Id.";
telemetry.Context.User.Id = "Test Device Id.";
telemetry.TrackEvent("Test TrackEvent");
Run Code Online (Sandbox Code Playgroud)
InstrumentationKey 正确。Telemetry.TractEvent 方法不会公开异常。Azure Application Insight 搜索(针对自定义事件)不显示历史记录。
谢谢。
我正在使用 ApplicationInsights.WorkerService nuget 包构建 .Net Core 后台服务。有关采样配置的文档表示请参考此: https: //learn.microsoft.com/en-us/azure/azure-monitor/app/sampling#configure-sampling-settings
它显示了这一点:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, TelemetryConfiguration configuration)
{
var builder = configuration.DefaultTelemetrySink.TelemetryProcessorChainBuilder;
// For older versions of the Application Insights SDK, use the following line instead:
// var builder = configuration.TelemetryProcessorChainBuilder;
// Using adaptive sampling
builder.UseAdaptiveSampling(maxTelemetryItemsPerSecond:5);
// Alternately, the following configures adaptive sampling with 5 items per second, and also excludes DependencyTelemetry from being subject to sampling.
// builder.UseAdaptiveSampling(maxTelemetryItemsPerSecond:5, excludedTypes: "Dependency");
// If you have other telemetry processors:
builder.Use((next) …Run Code Online (Sandbox Code Playgroud) 我有一个S2AppService 计划,其中有一个实例计数为1(默认)的 Web 作业。Webjob 基本上使用5(可配置的)并发线程从服务总线主题读取。
最近,我们的负载很大,webjob 无法快速读取 SB Topic 中的所有消息,因此我们增加了实例计数1 to 10和线程5 to 10。
我想了解网络作业的线程计数与应用程序服务的线程计数指标是否有任何关系?如果是,我仍然看到最大线程数为35。如果不是,有没有办法在任何时间正确测量我的网络作业的活动线程数?
azure azure-webjobs azure-app-service-plans azure-web-app-service
我需要编写一个 PowerShell 脚本 shell 来将条目记录到 App Insights 中。我发现这篇文章很有用,但我很难写到除了那里使用的领域之外的不同领域。例如,我正在尝试填充消息字段。我不知道 JSON 中的字段名称,也不知道它应该去哪里。正如你在这个例子中看到的,我尝试将它放置在任何地方,但仍然不起作用。我尝试搜索他们的 REST API 文档,但仍然找不到 JSON 的规范。有人可以帮忙吗?
[{
"name": "Microsoft.ApplicationInsights.Event",
"time": "2018-09-20T16:57:16.1771869Z",
"iKey": "1234",
"message": "This is a message",
"tags": {
"ai.operation.name": "Name",
"ai.user.id": "userId",
"ai.cloud.roleInstance": "Machine 1"
},
"data": {
"baseType": "EventData",
"message": "message1",
"baseData": {
"name": "Event from my service",
"message": "message2",
"properties": {
"x": "value x",
"y": "value y",
"z": "value z"
}
}
}
}]
Run Code Online (Sandbox Code Playgroud) 我很困惑我在 List 的 ForEach 方法语法中做错了什么?
PS D:\ntt> $nicInfo.IpConfigurations.Count
2
PS D:\ntt> $nicInfo.IpConfigurations[0]
PrivateIpAddressVersion Name Primary PrivateIpAddress PrivateIpAllocationMethod Subnet Name PublicIpAddress Name ProvisioningState
----------------------- ---- ------- ---------------- ------------------------- ----------- -------------------- -----------------
IPv4 ipconfig1 True 10.233.0.4 Dynamic Succeeded
PS D:\ntt> $nicInfo.IpConfigurations.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True List`1 System.Object
PS D:\ntt> $nicInfo.IpConfigurations.ForEach({$_})
PS D:\ntt>
Run Code Online (Sandbox Code Playgroud) 我正在将文件从 Azure 文件共享复制到存储容器中的 CloudBlockBlob。在删除原始文件之前,我想验证两个位置的字节 (.Properties.Length) 是否相同。我认为这是获得对复制的 blob 的新引用的情况,但它始终为 -1。
副本工作正常,对文件 v blob 的目视检查显示字节是相同的,只是不确定如何在我的 C# 应用程序中复制它。
我遇到问题的那一行是定义“复制”对象的那一行。
string myfile = @"junk.txt";
CloudFile sourcefile =
fileStorage.Share.GetRootDirectoryReference().GetFileReference(myfile);
CloudBlockBlob destBlob =
destStorage.Container.GetBlockBlobReference(myfile);
string fileSAS = sourcefile.GetSharedAccessSignature(new
SharedAccessFilePolicy()
{
Permissions = SharedAccessFilePermissions.Read,
SharedAccessExpiryTime = DateTime.Now.AddHours(24)
});
Uri fileUri = new Uri(sourcefile.StorageUri.PrimaryUri.ToString() + fileSAS);
CloudBlockBlob destBlob = destStorage.Container.GetBlockBlobReference(file.Path);
destBlob.StartCopy(fileUri);
CloudBlockBlob copied = destStorage.Container.GetBlockBlobReference(myfile);
Run Code Online (Sandbox Code Playgroud) 有很多教程使用以下代码通过 WebJob SDK 3.0 库创建 Webjobs。特别是“定时器触发器”
public void DoSomethingUseful([TimerTrigger("0 */1 * * * *", RunOnStartup = false)] TimerInfo timerInfo, TextWriter log)
{
// Act on the DI-ed class:
string thing = _usefulRepository.GetFoo();
Console.WriteLine($"{DateTime.Now} - {thing}");
}
Run Code Online (Sandbox Code Playgroud)
上面的例子应该每 1 分钟将这个方法作为一个 webjob 运行一次。然而这行不通。
在包含 setting.job 文件时,我已经设法让 webjob 工作。
setting.job: { "schedule": "0 */1 * * * *" }
Run Code Online (Sandbox Code Playgroud)
我的问题是这两者有什么不同?
这与 Azure 事件中心有关,我正在尝试使用 POSTMAN 的 POST api 调用将数据发送到我的事件中心。
我遵循的步骤:
创建事件中心、生成 SAS 发送令牌、创建消费者组
现在在邮递员中,我正在努力格式化正确的标题:
我发送的请求:
POST: https://testeventhu.servicebus.windows.net/myhub
Run Code Online (Sandbox Code Playgroud)
2个标题:
Content-Type : application/atom+xml;type=entry;charset=utf-8
Authorization: SharedAccessSignature sig=kjheh/f6SqR8dIW2nRpGUCHuhdshss2KoCKo7Q6ozmY=&se=1571140739&skn=saspolicy&sr=https://testeventhu.servicebus.windows.net/myhub
Run Code Online (Sandbox Code Playgroud)
我收到错误 401 MalformedToken: Failed to parse simple web token
我在这里做错了什么?使用的参考来自 https://docs.microsoft.com/en-us/rest/api/eventhub/Send-event?redirectedfrom=MSDN
提前致谢
我正在使用 .NET Framework 开发 Azure webjob,但是当我在本地运行时,启动后出现此异常。
Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException:函数的侦听器[Name of function]无法启动。内部异常:
ArgumentNullException: 值不能为空。
参数名称:connectionString
这是ProgramWeb 作业类中的代码。
static void Main()
{
HostBuilder builder = new HostBuilder();
builder.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices();
b.AddTimers();
});
using (IHost host = builder.Build())
{
host.Run(); // <-- error happens on this line
}
}
Run Code Online (Sandbox Code Playgroud)
在里面App.config我添加了接下来的两个连接字符串:
<add name="AzureWebJobsDashboard" connectionString="DefaultEndpointsProtocol=https;AccountName=[Name];AccountKey=[Key]" />
<add name="AzureWebJobsStorage" connectionString="DefaultEndpointsProtocol=https;AccountName=[Name];AccountKey=[Key]" />
Run Code Online (Sandbox Code Playgroud)
使用[Name]和[Key]作为来自实时环境的帐户名称 en 键。
此外,当我将连接字符串更改为 时UseDevelopmentStorage=true,我也遇到了相同的异常。
我怎么能解决这个问题?
我有一个存储容器,里面有 3 层目录,如下所示:
--Container
--Folder1
--Folder2
--Folder3
--blobs here
Run Code Online (Sandbox Code Playgroud)
我需要检查Folder3 中是否存在任何斑点,或者更好的是检查Folder3 是否存在。我尝试使用
blob_exist = BlobClient.from_connection_string(conn_str = os.getenv("conString"), container_name="Container",blob_name="Folder1/Folder2/Folder3").exists()
无论文件夹是否存在,它总是返回False 。谁能告诉我如何实现这一目标?
我知道 Blob 容器中不存在空文件夹,但我的意图是检查文件夹是否存在,然后继续其他业务逻辑。