无local.settings.json时,如何在Azure DevOps管道启动dotnet-isolated Azure Function
解决Azure DevOps管道中以dotnet-isolated模式启动Azure Function的问题
方法一:执行func start前设置环境变量
FUNCTIONS_WORKER_RUNTIME本质是环境变量,无需依赖local.settings.json,可以在启动命令前直接配置:
- Windows命令行任务:
set FUNCTIONS_WORKER_RUNTIME=dotnet-isolated func start - Bash任务(Linux/macOS代理):
export FUNCTIONS_WORKER_RUNTIME=dotnet-isolated func start
方法二:生成临时极简local.settings.json
在管道中创建仅包含必要配置的临时文件,既避免敏感信息提交,又满足启动要求:
- PowerShell任务示例:
@' { "IsEncrypted": false, "Values": { "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" } } '@ | Out-File local.settings.json -Encoding utf8 func start - Bash任务示例:
cat > local.settings.json << EOF { "IsEncrypted": false, "Values": { "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" } } EOF func start
上述两种方法都能让func start识别dotnet-isolated运行时,避免出现Did not find functions with language [dotnet]的错误。
内容的提问来源于stack exchange,提问作者Rob Bowman
相关产品推荐
相关产品推荐

