小编Iva*_*ang的帖子

将 Azure Functions 从“消费计划”切换到“高级计划”

有谁知道如何将“消费计划”上的 Azure Functions 更改为“高级计划”?我无法再次重新部署它们,我需要将它们切换到高级计划。我没有找到任何相关手册如何操作。

在此输入图像描述

azure azure-functions

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

Application Insights 的日志未写入跟踪日志

我按照此页面Application Insights 说明将 Application Insights (AI) 添加到我的 Web API 服务。我设法让我的服务连接到人工智能,并且我能够看到我的服务何时执行发布、获取等。我还通过我的服务发出了日志调用,但它们都没有写入我的人工智能的跟踪日志。

痕迹日志

我确保设置 Startup.cs 和 appsettings.json 文件以包含在整个服务中运行 AI 所需的新代码,并且日志数据需要让 AI 抓取日志进行调试和启动。

启动.cs

public void ConfigureServices(IServiceCollection services)
{         
    services.AddApplicationInsightsTelemetry();
}
Run Code Online (Sandbox Code Playgroud)

应用程序设置.json

应用程序设置.json

记录示例

public async Task ProcessQueueAsync(dBData dbContext)
{
    // _logger is of type ILogger<[INSERT CLASS NAME]>
    _logger.LogDebug("This is a test log by Lotzi11.");
    await ProcessQueueAsyncSingle(dbContext, CancellationToken.None);
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮我弄清楚为什么我的日志没有发送到人工智能吗?

c# serilog azure-application-insights asp.net-core-webapi

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

在写入期间锁定 Azure blob

我必须更新存储为 Azure blob 的大文件。此更新将需要几秒钟,我需要确保没有其他客户端获得部分更新的文件。

https://docs.microsoft.com/en-us/azure/storage/common/storage-concurrency 中所述,锁定文件进行写入应该很容易,但据我所知,其他客户端仍然可以读取文件。我可以使用读锁,但这意味着只有一个客户端可以读取文件,这不是我想要的。

根据防止 azure blob 在创建时被其他服务访问,似乎至少会在上传结束时“提交”新文件,但我找不到更新现有文件时会发生什么的信息。

所以,问题是:在更新(替换)操作期间其他客户端会读取什么?

  • 他们会在提交新数据之前读取旧文件还是
  • 他们会读取部分更新的文件内容吗?

c# azure azure-blob-storage

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

在 C# 中从 AppInsights 读取 JSON 输出

我想在 C# 控制台应用程序中读取 AppInsights API 输出。

WebClient wc = new WebClient();
wc.BaseAddress = "https://api.applicationinsights.io/v1/apps/AppInsighID/query?query=requests|where timestamp>= ago(1h)|limit 100";
wc.Headers.Add("Host", "api.applicationinsights.io");
wc.Headers.Add("x-api-key", "key");

string json = wc.DownloadString("");

JObject jsonObject = JObject.Parse(json);

//With this, i got values for Rows

var rowsObject = jsonObject["tables"][0]["rows"];
Run Code Online (Sandbox Code Playgroud)

现在值在数组中,在 rowObject 下,那么如何读取呢?

我也想知道在阅读 json 字符串时我们应该遵循的最佳实践

我可以看到这样的数据

{
"tables": [
    {
        "name": "PrimaryResult",
        "columns": [
            {
                "name": "timestamp",
                "type": "datetime"
            },
            {
                "name": "id",
                "type": "string"
            },
            {
                "name": "source",
                "type": "string"
            },
            {
                "name": "name",
                "type": "string"
            },
            { …
Run Code Online (Sandbox Code Playgroud)

c# json azure-application-insights

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

并非所有日志级别都记录在 Application Insights 中

我有一个应用程序设置为使用 Application Insights,并且我正在尝试手动记录一些自定义信息。这是我的控制器:

public class MyController : Controller
{
    private ILogger<MyController> Logger { get; set; }

    public MyController(ILogger<MyController> logger)
    {            
        Logger = logger;
    }

    public IActionResult Index()
    {
        Logger.LogCritical("Test critical");
        Logger.LogError("Test error");
        Logger.LogWarning("Test warning");
        Logger.LogInformation("Test information");
        Logger.LogDebug("Test debug");
        Logger.LogTrace("Test trace");

        ...
    }
Run Code Online (Sandbox Code Playgroud)

我的 Startup.cs 中有这个:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    loggerFactory.AddConsole(Configuration.GetSection("Logging"));
    loggerFactory.AddDebug();
    loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Warning);
    ...
Run Code Online (Sandbox Code Playgroud)

}

这在我的 Program.cs 中:

public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseApplicationInsights()
            .UseStartup<Startup>()
            .Build();
Run Code Online (Sandbox Code Playgroud)

在我的 appsettings.json 中:

"Logging": {
  "IncludeScopes": false, …
Run Code Online (Sandbox Code Playgroud)

c# asp.net azure azure-application-insights

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

我在 Azure 日志流中看不到日志

我正在尝试记录我的 ASP.NET Core 应用程序的信息,但我找不到在 Azure 日志流中显示 loogs 的方法。当我在 Visual Studio 中调试时,应用程序成功记录日志,但在发布到 Azure 时看不到任何内容。

这是我的应用服务日志的样子: 应用服务日志

我尝试使用我在 Microsoft 文档中找到的不同方法进行登录,但都没有奏效。

    [HttpGet]
    public string Index()
    {
        Trace.TraceInformation("You are in the face recognition controller. Trace");
        _logger.LogInformation("You are in the face recognition controller. Logger");
        return "You are in the face recognition controller";
    }
Run Code Online (Sandbox Code Playgroud)

控制器构造函数:

    private readonly ILogger _logger;
    public FaceRecognitionController(ILoggerFactory loggerFactory)
    {
        _logger = loggerFactory.CreateLogger<FaceRecognitionController>();
    }
Run Code Online (Sandbox Code Playgroud)

配置方法:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        loggerFactory.CreateLogger("console");
        loggerFactory.CreateLogger("debug");

        app.UseHttpsRedirection();

        app.UseRouting(); …
Run Code Online (Sandbox Code Playgroud)

c# logging azure azure-web-app-service asp.net-core-3.1

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

在 Angular 的应用洞察中设置 cloud_RoleName

在asp.net的服务中,我们可以为应用程序洞察设置cloud_rolename。使用此功能,我们的服务团队可以跟踪应用程序洞察中的错误。我如何从角度设置它。这就是我以角度运行应用程序洞察的方式:

export class MonitoringService {
private appInsights: ApplicationInsights;
 constructor(private router: Router) {
  this.appInsights = new ApplicationInsights({
   config: {
     instrumentationKey: environment.appInsights.instrumentationKey,
  },
});
this.appInsights.loadAppInsights();
this.loadCustomTelemetryProperties();
this.createRouterSubscription();
Run Code Online (Sandbox Code Playgroud)

}

azure azure-application-insights angular

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

C# Application Insight 失败:TrackEvent 未发送到 Azure Application Insight

我对 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 搜索(针对自定义事件)不显示历史记录。

谢谢。

azure azure-application-insights

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

如何在 Net Core HostBuilder 上配置 Application Insights 采样?

我正在使用 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)

azure azure-application-insights .net-core

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

Python 应用程序的 Azure Application Insights 日志记录 - 显式设置异常属性

我正在尝试将异常从在Azure 应用程序服务中运行的Python 应用程序发送到指定的Azure Application Insights实例。我正在使用OpenCensus python 库来实现此目的。基本日志记录和异常已成功到达 App Insight。

除此之外,我想知道是否有一种方法可以配置异常属性,例如:problemId或任何其他属性显式地反映特定值以便更容易发出警报(例如根据 ProblemId 向特定组发送电子邮件)。

任何建议/指示都会非常有帮助

python azure-application-insights opencensus azure-appservice

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