单个 func.exe 是否可以承载多个函数项目?
我有一个函数应用程序 DLL 项目,我希望能够通过配置更改计时器触发器的时间表,但该时间表作为属性参数传递。这意味着我只能传递编译时值,而不能动态传递。
有没有办法从应用程序设置或其他地方读取它,这样每当我想更新时间表时就不必更改代码?
这是我目前使用属性参数的示例
[Function("MyTimeTriggeredFunction")]
public static async void Run([TimerTrigger("*/15 * * * * *")] TimerInfo timer, TraceWriter log)
{
log.Info("Doing some timely work ...");
// and other stuff .....
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用nodejs 和express 创建一个简单的hello world azure 函数应用程序。但是,我收到以下错误:
Exception while executing function: Functions.httpexpressapp. mscorlib: Unable to determine function entry point. If multiple functions are exported, you must indicate the entry point, either by naming it 'run' or 'index', or by naming it explicitly via the 'entryPoint' metadata property.
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
函数.json
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"type": "http",
"direction": "out",
"name": "res"
}
],
"entryPoint": "index",
"disabled": false
}
Run Code Online (Sandbox Code Playgroud)
索引.js:
const express = require('express') …Run Code Online (Sandbox Code Playgroud) azure node.js express azure-functions azure-functions-runtime
我正在尝试使用队列触发器创建一个函数,这是function.json:
"scriptFile": "__init__.py",
"bindings": [
{
"name": "CraigslistItemParser",
"type": "queueTrigger",
"direction": "in",
"queueName": "craigslist",
"connection": "DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY;EndpointSuffix=core.windows.net"
}
]
}
Run Code Online (Sandbox Code Playgroud)
在控制台日志中部署该函数时,出现错误:
The 'CraigslistItemParser' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.CraigslistItemParser'. Microsoft.Azure.WebJobs.Extensions.Storage: Storage account connection string 'DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY;EndpointSuffix=core.windows.net' does not exist. Make sure that it is a defined App Setting.
Run Code Online (Sandbox Code Playgroud)
什么是应用程序设置,我在任何地方都找不到它们?
在 Azure 函数中,如果“SecretUri”中没有版本号,Key Vault 引用是否也能正常工作
@Microsoft.KeyVault(SecretUri=https://MYKEYVAULT.vault.azure.net/secrets/secretkey/)
Run Code Online (Sandbox Code Playgroud)
我需要连接到没有任何版本的 Key Vault 密钥,以便在轮换密钥时无需更新应用程序配置中的版本。
我有一个由Azure Service Bus Queue触发的 Azure 函数。
功能如下。
AddContact触发器开始、检查方法中的逻辑以及使用输出绑定发送到 blob 的数据来完成集成测试? public static class AddContactFunction
{
[FunctionName("AddContactFunction")]
public static void Run([ServiceBusTrigger("AddContact", Connection = "AddContactFunctionConnectionString")]string myQueueItem, ILogger log)
{
log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
}
Run Code Online (Sandbox Code Playgroud) 我正在编写第一个计时器触发的函数,但在将它们配置为自行运行时遇到问题。为了便于解释,我们只关注其中一个。
函数记录为运行成功,但由于记录,我发现每次函数运行时“myTimer.past_due”都会返回“false”,并且函数逻辑不会启动。
我应该如何设置它才能可靠地返回“true”?
我应该如何设置它,以便它可以通过“测试代码”表单门户运行?
我在这里没有得到什么?是否还有其他定时器需要匹配?
我什至通过在 Azure 中设置新功能应用程序和存储帐户来“将其关闭并再次打开”,以确保我在此过程中没有破坏某些设置。
原理:这是一个ETL函数,通过API连接到第三方平台,并将所需数据插入到azure SQL数据库中。我希望它每天凌晨 1 点运行。对于启动函数脚本,我使用了通过 Microsoft DOC 页面提供的脚本,稍加修改,从这里开始: https: //learn.microsoft.com/pl-pl/azure/azure-functions/functions-bindings-timer ?tabs=python
这是我的“ init.py ”:
import datetime
import logging
import azure.functions as func
from Toggl_Data_Procurement_Function import toggl_script
def main(myTimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
logging.info(f"myTimer.past_due: {myTimer.past_due}")
if myTimer.past_due:
logging.info('Function %s, started by timer trigger, started running at %s', func.Context.function_name, utc_timestamp)
toggl_script.TogglDataProcurementScript(root_directory=str(func.Context.function_directory)).run()
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
logging.info('Function %s, started by timer trigger finished running at %s', func.Context.function_name, utc_timestamp)
Run Code Online (Sandbox Code Playgroud)
这是我的 function.json - 为了调试,我将其设置为每 15 …
我已在 Azure 应用程序配置中添加键值对,并尝试在 Startup.cs 类文件中读取它。请建议如何做到这一点。
public class Startup : FunctionsStartup
{
private static readonly string url= "*******************";
public override void ConfigureAppConfiguration(IFunctionsConfigurationBuilder builder)
{
string connectionString=????? //How to get this value from Azure app config
builder.Services.AddDbContext<DbContext, Context>(
options => SqlServerDbContextOptionsExtensions.UseSqlServer(options, connectionString));
builder.ConfigurationBuilder.AddAzureAppConfiguration(url);
}
}
Run Code Online (Sandbox Code Playgroud) 我发布了 Azure Functions,但收到此错误消息。
Microsoft.Azure.WebJobs.Script:找到名称为 XXX 的重复 FunctionMetadata。
我创建了一个azure持久函数并将其放入docker容器中,一切都在docker桌面中运行,azure持久函数正在使用和MQ兔子触发器。这是代码:
public async Task<List<string>> RunOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context
)
{
var job = context.GetInput<Job>();
var outputs = new List<string>();
try
{
job.JobCreationIdResult = await context.CallActivityAsync<string>("JobExecutor_CreateJobSimple", job);
}
catch (Exception ex)
{
_logger.ForContext<JobExecutorSimple>().Error(ex.Message, ex);
return outputs;
}
return outputs;
}
[FunctionName("JobExecutor_CreateJobSimple")]
public async Task<string> CreateJob([ActivityTrigger] Job job)
{
_logger.ForContext<JobExecutorSimple>().Information($"result JobId: {job.MktJobId}");
return "done";
}
[FunctionName("JobExecutor_RabbitMQStartSimple")]
public async Task RabbitMQStart(
[RabbitMQTrigger("mkt-executor-q-local", ConnectionStringSetting = "mkt-Executor-RabbitMqConnection")] Job job,
[DurableClient] IDurableOrchestrationClient starter)
{
string instanceId = await starter.StartNewAsync("JobExecutorSimple", job);
_logger.ForContext<JobExecutorSimple>().Information($"Started orchestration with ID = '{instanceId}'."); …Run Code Online (Sandbox Code Playgroud) 我尝试使用 python 在本地运行我的 Azure Functions,收到的错误消息如下:
[2023-03-03T11:34:59.832Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup
code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
Run Code Online (Sandbox Code Playgroud)
我使用此命令创建了我的项目,并且没有更改生成的代码中的任何内容:
func init LocalFunctionProj --python -m V2
Run Code Online (Sandbox Code Playgroud)
当我尝试使用此命令运行应用程序时,我收到上述错误消息:
func start --verbose
Run Code Online (Sandbox Code Playgroud)
我在 python v3.10 上运行它。另外,当我尝试创建 V1 python 函数时,它工作没有任何问题。
有什么想法为什么会发生这种情况吗?
我创建了一个函数应用程序来处理计时器触发函数,创建它后,我可以创建函数,但函数部分中缺少 Function(fx) 选项。是新功能还是我错过了什么?
我要求我必须TEntity在课堂上使用.但是在将Generics与类一起使用时,Azure功能无法正常工作.它甚至没有在控制台上显示.但是,如果我TEntity从类声明中删除它在控制台中显示.所以这不受支持吗?或者有任何解决方法吗?我在互联网上搜索过但发现与此无关.
public static class DataFilesIngestJobs<TEntity>
{
[FunctionName("IngestDataFilesScheduled")]
public static async Task RunScheduleAsync(
[TimerTrigger("%DataFiles:IngestJob:ScheduleExpressionTrigger%")] TimerInfo timer,
ExecutionContext context,
TraceWriter log)
{
await RunAsync(context, log);
}
[FunctionName("IngestDataFilesOnDemand")]
public static async Task RunOnDemandAsync(
[QueueTrigger("%DataFiles:IngestJob:OnDemandQueueNameTrigger%", Connection = "ConnectionStrings:BlobStorageAccount")] string queueItem,
ExecutionContext context,
TraceWriter log)
{
await RunAsync(context, log);
}
}
Run Code Online (Sandbox Code Playgroud)
TEntity从类中删除时的控制台输出.
找到了以下功能:[3/21/2018 6:52:41 AM] MyCompany.MyProject.DataFilesIngestJobs.RunScheduleAsync [3/21/2018 6:52:41 AM] MyCompany.MyProject.DataFilesIngestJobs.RunOnDemandAsync
azure-functions ×13
azure ×8
c# ×4
python ×2
python-3.x ×2
.net ×1
.net-core ×1
azure-aks ×1
azure-queues ×1
docker ×1
express ×1
generics ×1
node.js ×1
timer ×1
unit-testing ×1