我们目前正在Azure中为每个环境/每个区域部署一个功能应用程序.这些功能应用程序包含许多功能.随着服务计划设置为消耗,因此我们对此非常满意,因为它降低了ARM模板的操作复杂性.
我们确实想知道,如果最好在每个环境中拥有更多"功能应用程序"并在其中传播我们的功能吗?
这样做是否有任何实际好处,因为我们的印象表现将由动态服务计划扩展?
我需要为 Azure Functions 实施运行状况检查。
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-3.0
但是,在我的情况下,我们需要在 NETCORE 2.2 中实现它而不是使用 NETCORE 3.0
我们的主要问题是从FunctionsStartup继承的启动类,它与 MVC API 启动有很大的不同。因此,以下代码无法在 Startup.cs 中实现
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//Readiness check
var port = int.Parse(Configuration["HealthManagementPort"]);
app.UseHealthChecks("/ready", port, new HealthCheckOptions()
{
Predicate = (check) => check.Tags.Contains("ready"),
});
app.UseHealthChecks("/live", port, new HealthCheckOptions()
{
//Exclude all checks and return 200-OK
Predicate = (_) => false,
});
}
Run Code Online (Sandbox Code Playgroud)
有没有人遇到过类似的事情?我怎样才能实现类似的行为?
谢谢。
我正在尝试使用 SpecFlow 和 MSTest 测试(集成测试)我的 Azure Durable Function v3。
函数用 DI 和 Startup 类初始化:
[assembly: FunctionsStartup(typeof(Startup))]
namespace MyNamespace.Functions
{
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
ConfigureServices(builder.Services);
}
...
Run Code Online (Sandbox Code Playgroud)
Orchestrator 入口点由 HTTP 端点触发:
public class Function1
{
[FunctionName(nameof(Function1))]
public async Task<IActionResult> DoYourJob(
[HttpTrigger(AuthorizationLevel.Anonymous, methods: "post", Route = "api/routes/function1")] HttpRequestMessage httpRequest,
[DurableClient] IDurableOrchestrationClient starter)
{
...
Run Code Online (Sandbox Code Playgroud)
我的 IntegrationTest 构造函数初始化 Az 函数HostBuilder
(感谢这篇文章):
[Binding]
public sealed class Function1StepDefinitions
{
private readonly IHost _host;
private …
Run Code Online (Sandbox Code Playgroud) integration-testing azure .net-core azure-functions azure-durable-functions
将我的 Azure Functions 项目迁移到 .NET 5 后,它开始将我的响应包装在一个奇怪的包装类中。
例如,考虑以下端点:
public record Response(string SomeValue);
[Function("Get")]
public async Task<IActionResult> Get(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "get-something")]
HttpRequestData request)
{
return new OkObjectResult(new Response("hello world"));
}
Run Code Online (Sandbox Code Playgroud)
之前,它会返回:
{
"someValue": "hello world"
}
Run Code Online (Sandbox Code Playgroud)
但现在,它返回:
{
"Value": {
"SomeValue": "hello world"
},
"Formatters": [],
"ContentTypes": [],
"DeclaredType": null,
"StatusCode": 200
}
Run Code Online (Sandbox Code Playgroud)
我知道这一定是因为它只是尝试序列化对象结果,但我找不到任何关于它在 .NET 5 中应该如何工作的文档。
我的主要功能目前看起来像这样:
public static async Task Main()
{
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults(x =>
x.UseDefaultWorkerMiddleware())
.ConfigureAppConfiguration((_, builder) => builder
.AddJsonFile("local.settings.json", true)
.Build()) …
Run Code Online (Sandbox Code Playgroud) 我最近为 C# 中的 Azure Function 项目从 .NET Core 3.1 迁移到 .NET 5.0(使用隔离/进程外运行时)。一切都按预期工作。然而,每当我调试时,我的断点都没有命中。为什么我现在不能调试我的 Azure Function 应用程序,但我以前可以?
我无法在应用服务计划中找到有关Azure功能隔离的大量文档.
如果您共享一个静态变量,例如,HttpClient
在azure函数调用之间,我假设读取可以在同一进程或单独的进程或单独的服务器中运行的可伸缩性建议......这很好,使用Lazy<T>
可以帮助解决线程问题.
但是可以将Azure Functions分开一个工作进程吗?即我应该隔离静态变量以确保功能的隔离?我收集使用ConcurrentDictionary
带有键的函数是一个很好的方法来帮助解决这个问题,但我还没有找到任何讨论隔离的文档.
我有一个Azure功能应用程序(使用更新的.net class library
方法),我使用静态构造函数初始化,以便共享生成的资源.
官方文档建议像HttpClient
在web api中共享资源.
Azure函数C#脚本开发人员参考文档底部的讨论提到放置HttpClient
一个静态变量以防止对每个请求进行重新实例化,因为它是线程安全的.
我想知道两件事.
静态构造函数是否可以初始化所有请求使用的昂贵的"设置"资源?
如果这种方法没问题,如果这些资源的初始化失败,如何在静态构造函数中配置错误日志记录?
这是我的班级定义
public static class HttpSubmissionTrigger
{
private static readonly SendGridClient sendGridClient;
private static readonly Func<IDictionary<string, object>, string> template;
private static readonly EmailAddress senderEmail;
private static readonly string emailTitle;
private static readonly HttpResponseMessage errorResponse;
static HttpSubmissionTrigger()
{
// ... initialization of above static members here
}
public static async Task<HttpResponseMessage> Run(...)
{
// ... use static members here to send emails, respond to client …
Run Code Online (Sandbox Code Playgroud) 我想使用Application Insights来监控链接多个Azure功能的逻辑应用程序.我希望链尽可能安全,如果出现问题,我想让http请求无法被函数正确处理.我想我可以在出现问题时从Application Insights发出警报,但是我不确定如何将失败的消息发送到blob或"失败的消息队列"中.
Application Insights Alert是否可以成为将数据添加到blob的函数的触发器?
azure azure-application-insights azure-logic-apps azure-functions
我部署了V2函数,该函数具有未处理的异常。我希望(并认为是在V1中)在错误日志中看到堆栈跟踪和行号,但是我得到的只是:
System.Private.CoreLib:执行功能:MyFunction时发生异常。MyProjectNameToCall:对象引用未设置为对象的实例。
我需要设置一些配置才能看到它吗?
谢谢
因此标题几乎说明了一切!
我有一个编译为PWA的Angular 7应用,我的package.json在下面。我的后端api是用AzureFunctions V2编写的。
"dependencies": {
"@angular-devkit/core": "^7.0.5",
"@angular/animations": "^7.0.3",
"@angular/cdk": "^7.0.3",
"@angular/common": "^7.0.3",
"@angular/compiler": "^7.0.3",
"@angular/core": "^7.0.3",
"@angular/flex-layout": "^7.0.0-beta.19",
"@angular/forms": "^7.0.3",
"@angular/http": "^7.0.3",
"@angular/material": "^7.0.3",
"@angular/platform-browser": "^7.0.3",
"@angular/platform-browser-dynamic": "^7.0.3",
"@angular/platform-server": "^7.0.3",
"@angular/pwa": "^0.10.5",
"@angular/router": "^7.0.3",
"@angular/service-worker": "^7.0.3",
"@types/date-fns": "^2.6.0",
"angular-calendar": "^0.26.4",
"chartist": "^0.11.0",
"core-js": "^2.5.7",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3",
"zone.js": "^0.8.26"
},
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,当我将api端点设置为使用https时,出现504网关超时错误。我知道https的配置/功能很好,因为这都是由Azure使用Azure Functions自动配置的。
我所有的API请求也都可以通过https与Postman一起正常工作。
更新-有点发展,如果我在未启用PWA的情况下在本地运行,则会得到以下不同的ERR_SPDY_PROTOCOL_ERROR
这是Chrome中的调试信息 chrome://net-internals/#events
t=9314 [st= 1] UPLOAD_DATA_STREAM_READ [dt=0]
--> current_position = 0
t=9314 [st= 1] HTTP2_STREAM_UPDATE_SEND_WINDOW
--> delta = -73
--> stream_id = 3 …
Run Code Online (Sandbox Code Playgroud) azure-functions ×10
azure ×7
c# ×5
.net-core ×2
.net ×1
.net-5 ×1
angular-pwa ×1
angular7 ×1
asp.net-core ×1
static ×1