小编Pan*_*wat的帖子

ApplicationInsights OperationId 为空

我正在实现自定义 ApplicationInsights 记录器,并且能够在跟踪、异常和请求等写入位置写入所有日志,但跟踪和异常中的 OperationId 为空。

昨天我使用相同的代码并在所有表中获取 OperationId。之后我在玩多线程场景,效果不佳。现在我用简单的代码重新开始,但看不到 OperationId。

我的代码有什么问题?

public static class Function2
{
    private static TelemetryClient telemetryClient = new TelemetryClient(new Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration
    {
        InstrumentationKey = "********-****-********-****"
    });

    [FunctionName("Function2")]
    public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)]HttpRequestMessage req)
    {
        RequestTelemetry requestTelemetry = new RequestTelemetry { Name = "Function2" };
        var operation = telemetryClient.StartOperation(requestTelemetry);

        telemetryClient.TrackTrace("trace message", SeverityLevel.Error);
        telemetryClient.TrackException(new System.Exception("My custom exception"));


        operation.Telemetry.Success = true;
        telemetryClient.StopOperation(operation);

        return req.CreateResponse(HttpStatusCode.OK, "Hello ");
    }
}
Run Code Online (Sandbox Code Playgroud)

c# azure azure-application-insights

3
推荐指数
1
解决办法
1870
查看次数

无法评估扩展元数据的“Cosmos.CRTCompat.dll”。异常消息:IL 格式错误

我在 Visual Studio 2019 中发布 azure 函数时收到以下警告。

无法评估扩展元数据的“Cosmos.CRTCompat.dll”。异常消息:IL 格式错误。无法评估扩展元数据的“Microsoft.Azure.Documents.ServiceInterop.dll”。异常消息:IL 格式错误。

我在一个空白项目中尝试了相同的操作,但出现了相同的警告。

我在 VS Code 中看到同样的问题

C:\Users\pankaj.ra.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.5\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(63,5):警告:无法评估“Cosmos.CRTCompat.dll”以获取扩展元数据。异常消息:IL 格式错误。

我的函数项目文件

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="4.1.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.5" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  <CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)

azure visual-studio azure-functions

3
推荐指数
1
解决办法
4561
查看次数

CosmosDB Join(SQL API)

我正在使用SQL API使用CosmosDB,并且试图合并两个集合。我在文档中看到了join示例,但没有得到实际的外观。

请求日志

{
"DateTimeStamp": "2018-03-16T10:56:52.1411006Z",
"RequestId": "8ce80648-66e2-4357-98a8-7a71e8b65301",
"IPAddress": "0.0.0.173"
}
Run Code Online (Sandbox Code Playgroud)

响应日志

{
"DateTimeStamp": "2018-03-16T10:56:52.1411006Z",
"RequestId": "8ce80648-66e2-4357-98a8-7a71e8b65301",
"Body": "Hello"
}
Run Code Online (Sandbox Code Playgroud)

是否可以同时加入这两个系列?怎么样?

azure azure-cosmosdb

2
推荐指数
2
解决办法
4570
查看次数

垃圾收集如何决定变量的生成

我知道GC有3(0,1,2)代,但我想知道GC如何决定变量的生成?

我认为所有变量都进入第0代,经过一段时间后转移到第1代和第2代.对于GC来说,决定生成是否重要?

PROGRAM1:

private static void Main(string[] args)
{
        int a = 0;
        string name = "Test";
        var byteArray = new byte[10];
        byteArray[4] = 4;

        Console.WriteLine($"Generation of array {GC.GetGeneration(byteArray)}");
        Console.WriteLine($"Generation of local int variable {GC.GetGeneration(a)}");
        Console.WriteLine($"Generation of local string variable {GC.GetGeneration(name)}");
}
Run Code Online (Sandbox Code Playgroud)

结果

Generation of array 0
Generation of local int variable 0
Generation of local string variable 0
Run Code Online (Sandbox Code Playgroud)

程序2:

private static void Main(string[] args)
{
        int a = 0;
        string name = "Test";
        var byteArray = new byte[100000000];
        byteArray[4] …
Run Code Online (Sandbox Code Playgroud)

c# garbage-collection memory-management

1
推荐指数
1
解决办法
682
查看次数

在 Azure Function 中安装 Powershell 模块

我将 Azure Function 2.0 与 Powershell 结合使用,但在安装 Powershell 模块时出现以下错误。

有什么办法可以消除这个错误。一般来说,我们不需要管理员权限来安装 NuGet/依赖项。

我还尝试了另一种方法将所有 Powershell 模块放在 Modules 文件夹下 在此输入图像描述

尽管如此,函数仍无法找到 Cosmos DB 模块

在此输入图像描述

powershell azure azure-functions

1
推荐指数
1
解决办法
7706
查看次数