所以我一直在尝试创建一个简单的 azure 函数,这将是一个 http 触发器“CreateUser”。
我做了另一个 http 触发器来简化问题,它看起来很简单:
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
namespace TutoTableAzureTemplate
{
public static class TestTrigger
{
[FunctionName("TestTrigger")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
{
return req.CreateResponse(HttpStatusCode.OK, "This request arrived succcesfully");
}
}
}
Run Code Online (Sandbox Code Playgroud)
这在模拟器上运行,给我带来了以下错误:
Error indexing method 'TestTrigger.Run'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'log' to type TraceWriter. Make sure the parameter Type is supported by the binding.
Run Code Online (Sandbox Code Playgroud)
(我的模拟器版本是 5.3)
我试图删除参数TraceWriter log …
我使用 Visual Studio 代码创建了一个函数应用程序,然后发布了它。功能应用程序运行良好。我现在在功能门户中使用代码部署功能(KUDU)并跳过构建。下面是日志
9:55:46 AM Updating submodules.
9:55:47 AM Preparing deployment for commit id '5642d3aeec'.
9:55:48 AM Skipping build. Project type: Run-From-Zip
9:55:48 AM Skipping post build. Project type: Run-From-Zip
9:55:48 AM Triggering recycle (preview mode disabled).
9:55:49 AM Syncing 4 function triggers with payload size 452 bytes successful.
9:55:50 AM Deployment successful.
Run Code Online (Sandbox Code Playgroud)
当代码签入到 Github 时,部署就发生了。但它没有选择最新的代码。我确实将应用程序设置 WEBSITE_RUN_FROM_PACKAGE 设置为“1”。
我需要进行哪些更改才能选择最新版本。
提前致谢
我有这个非常简单的 .NET Core 应用程序:
static void Main(string[] args)
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
builder.AddAzureKeyVault("https://MyKeyVault.vault.azure.net");
var stopwatch = new Stopwatch();
stopwatch.Start();
var configuration = builder.Build();
var elapsed = stopwatch.Elapsed;
Console.WriteLine($"Elapsed time: {elapsed.TotalSeconds}");
}
Run Code Online (Sandbox Code Playgroud)
csproj 文件如下所示:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
我的问题是应用程序需要大约 10 秒才能在附加调试器的情况下执行(在没有调试器的情况下大约需要 5 秒)。如果我使用AddAzureKeyVault删除该行,应用程序将在不到一秒的时间内执行。我知道AddAzureKeyVault …
背景
我有一个遗留站点,允许授权用户上传产品数据等的 Excel 电子表格。然后该站点读取 Excel 工作表并将数据解压缩到 SQL 服务器中。这是一个旧站点,它使用 OLE。旧但有效。
这个问题
我最近出版的网站到Azure的应用服务,但是,从Excel读取我的代码的现有部分不工作(如Azure不具有正确的驱动程序)。
这个问题
我很高兴能改写这部分代码,但什么是使用Azure的应用服务从Excel读取正确或推荐的方法呢?我不是在问可能起作用的方法,我只对正确的方法感兴趣。
“推荐”是指:
我已经研究过这个问题,但没有找到一个明确的声明来说明最好的方法。如果您有不同方法的经验或知识,如果您能分享关于最佳方法的结论,我将不胜感激。
我正在编写一个 Azure 函数,它将更新 Azure DNS 区域。该函数具有附加的托管服务标识 (MSI)。
我可以使用非流畅 SDK 读取 DNS 区域中的当前记录。但是,当我尝试使用 fluent 库做同样的事情时,我收到以下错误:
[07/11/2018 14:36:37] 执行“Function1”(失败,Id=8d34472e-956a-4ff3-a1b1-16ea6186934a)
[07/11/2018 14:36:37] System.Private.CoreLib:执行函数时出现异常:Function1.Microsoft.Azure.Management.ResourceManager.Fluent:值不能为空。
[07/11/2018 14:36:37] 参数名称:MSI_ENDPOINT。
为了可以轻松测试两个库之间的差异,我整理了一个测试函数。
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Management.ResourceManager.Fluent.Authentication;
using Microsoft.Azure.Management.ResourceManager.Fluent;
using Microsoft.Azure.Management.Fluent;
using Microsoft.Azure.Services.AppAuthentication;
using Microsoft.Rest;
using Microsoft.Azure.Management.Dns;
using Microsoft.Azure.Management.ResourceManager.Fluent.Core;
namespace UpdateDNS
{
public static class Function1
{
[FunctionName("Function1")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "{subscription}/{rg_name}/{zone_name}/{lib}")] HttpRequest req,
string subscription,
string rg_name,
string zone_name,
string …
Run Code Online (Sandbox Code Playgroud) 我有一个带有计时器触发器的 Azure 函数。时间表为“0 0 18 * * 周一至周五”。我可以手动运行它,但它不会自动触发。我看到一些答案说应用服务计划不能是“经典”,但我没有看到该选项。我的函数应用程序的应用程序服务计划是基于消耗的。有什么建议吗?
这是 function.json:
{
"generatedBy": "Microsoft.NET.Sdk.Functions-1.0.24",
"configurationSource": "attributes",
"bindings": [
{
"type": "timerTrigger",
"schedule": "0 0 18 * * MON-FRI",
"useMonitor": true,
"runOnStartup": false,
"name": "myTimer"
}
],
"disabled": false,
"scriptFile": "../bin/MyApp.dll",
"entryPoint": "MyApp.ProcessOptions.Run"
}
Run Code Online (Sandbox Code Playgroud) 我已经部署了一个从 identityserver4 的快速入门构建的项目(https://github.com/IdentityServer/IdentityServer4.Demo )。只要我在本地运行它,它就可以完美运行,但是当我将它部署到 Azure 时,索引页返回 404,但是当我手动转到其他路由(如“/account/login”)时,它们按预期工作。
我的 Startup.cs:
using System;
using System.Linq;
using System.Threading.Tasks;
using LunchBucks.Auth.Extensions;
using LunchBucksEncryption;
using LunchBucksEncryption.PasswordHashing;
using LunchBucksEncryption.SaltGeneration;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace LunchBucks.Auth
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<ISaltGeneration, SaltGeneration>();
services.AddTransient<IPasswordHashing, PasswordHashing>();
services.AddTransient<IEncryptionManagement, EncryptionManagement>();
services.AddMvc(); …
Run Code Online (Sandbox Code Playgroud) 我已经使用 ASP.NET 创建了一个 Web 服务,并将数据存储在 Firestore 中。因此,我需要设置引用 JSON 文件的 GOOGLE_APPLICATION_CREDENTIALS 环境变量。这在我的计算机上本地工作,但在发布到 Azure 时不起作用。问题是我找不到 JSON 文件来定位文件路径,我在发布之前仔细检查了本地项目文件夹是否存在 JSON 文件。我可以知道存储 JSON 文件的最佳位置在哪里,以便我可以找到文件路径并且 GOOGLE_APPLICATION_CREDENTIALS 可以在 Azure 门户中引用它。
谢谢。
environment-variables azure asp.net-web-api azure-web-app-service google-cloud-firestore
AcceptedAtRouteResult
从 Azure 函数返回时,我不断收到无法处理的主机错误。
我希望能够AcceptedAtRouteResult
从 Azure 函数返回一个,以告诉调用者任何省略的查询字符串参数的默认值,但我不断收到未处理的主机错误。
我的目标是 .net Standard 2.0.3 并使用 Microsoft.NET.Sdk.Functions 1.0.26
[FunctionName("AcceptedAtRouteResult")]
public static IActionResult AcceptedAtRouteResult(
[HttpTrigger("GET")]HttpRequest req)
{
// read query parameter if present else set to defualt value
var rs = new AcceptedAtRouteResult(
"acceptedatrouteresult",
new { someParameter = "value" },
new { Result = "1" });
return rs;
}
Run Code Online (Sandbox Code Playgroud)
我不断收到异常:
发生了未处理的主机错误。System.Private.CoreLib:索引超出范围。必须是非负的并且小于集合的大小。参数名称:索引。
我确实遵循了https://docs.microsoft.com/da-dk/azure/azure-functions/functions-host-json#functiontimeout 中提到的指南,将应用服务计划中函数应用主机的默认超时时间从 30 分钟增加到通过使用 "functionTimeout": "02:00:00" 更新主机文件到 2h
在检查函数应用程序的事件查看器日志时,我可以看到超时限制仍然是 30m。添加错误信息以供参考,
<EventData>
<Data>Application: w3wp.exe
CoreCLR Version: 4.6.27317.7
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.Azure.WebJobs.Host.FunctionTimeoutException: Timeout value of 00:30:00 was exceeded by function: CreateRequestApplicationPostProcessor
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryHandleTimeoutAsync(Task invokeTask, CancellationToken shutdownToken, Boolean throwOnTimeout, CancellationToken timeoutToken, TimeSpan timeoutInterval, IFunctionInstance instance, Action onTimeout) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 631
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker, ParameterHelper parameterHelper, CancellationTokenSource timeoutTokenSource, CancellationTokenSource functionCancellationTokenSource, Boolean throwOnTimeout, TimeSpan timerInterval, IFunctionInstance instance) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 547
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance, ParameterHelper …
Run Code Online (Sandbox Code Playgroud) 我想根据消息的内容创建订阅。这可能吗?我试图摆脱必须添加自定义属性。
谢谢
我正在使用Azure Logic App通过Outlook发送电子邮件。
但是,我无法使用HTML格式的[发送Outlook电子邮件]操作。
发送的邮件为纯文本格式。
如何使用Azure Logic App发送HTML电子邮件并发送Outlook电子邮件?
我有一个仅包含静态html页面的Azure网站。如何在响应中设置缓存控制标头?
azure ×13
c# ×3
.net ×1
.net-core ×1
asp.net-core ×1
excel ×1
filter ×1
outlook ×1
sql-server ×1
subscription ×1