You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

更换Mac电脑后Node.js Azure Functions部署异常求助

Node.js Azure Function App 部署异常排查(MacOS vs Linux)

从Ubuntu电脑切换到MacOS笔记本后,部署Node.js Azure Function App时出现异常:克隆代码仓库并复制local.settings.json到MacOS后,执行部署命令func azure functionapp publish workers-app-staging,CLI仅输出部署成功信息但未列出任何函数就退出,具体输出如下:

Getting site publishing info...
[2024-08-06T05:59:25.030Z] Starting the function app deployment...
Uploading package...
Uploading 43.42 MB [##############################################################################]
Upload completed successfully.
Deployment completed successfully.
[2024-08-06T05:59:47.200Z] Syncing triggers...
Functions in workers-app-staging:

而在Linux环境执行相同命令时,CLI会正常列出项目所有函数,函数也能成功部署并在Azure门户查看。

当前状态:无失败日志,存储桶中的zip文件已更新,WEBSITE_RUN_FROM_PACKAGE环境变量值正确(该Azure函数应用为Linux消耗计划),且已确认Linux与MacOS的配置一致。

环境版本信息

❯ func version                                                                                                                                                  
4.0.5907 

❯ npm list @azure/functions
workers-app@1.0.0 /Users/george/code/workers-app
└── @azure/functions@4.1.0

❯ node --version         
v18.20.4

函数代码示例

app.cosmosDB('forwardInvoiceOutEventsToTopic', {
  ...COSMOSDB_DEFAULT_CONFIG_WITH_LEASE,
  containerName: 'invoice-out-events',
  leaseContainerPrefix: 'forwardToTopic',
  maxItemsPerInvocation: 5,
  retry: DEFAULT_RETRY,
  handler: (document) => {console.log('this has a real implementation')}
})
app.eventGrid('invoiceOutGenerateDocument', {
  handler: (event) => {console.log('this has a real implementation')},
  return: output.cosmosDB({
    ...COSMOSDB_DEFAULT_CONFIG,
    containerName: 'invoice-out-events',
    createIfNotExists: false,
    connectionStringSetting: 'COSMOSDB_CONNECTION_STRING',
    collectionName: 'invoice-out-events'
  })
})
app.http('sandboxInsertInvoiceOut', {
  methods: ['GET', 'POST'],
  authLevel: 'anonymous',
  handler: (request) => {console.log('this has a real implementation')},
})

local.settings.json 配置

{
  "IsEncrypted": false,
  "Values": {
    "APPLICATIONINSIGHTS_CONNECTION_STRING": "InstrumentationKey=...",
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=...",
    "FUNCTIONS_EXTENSION_VERSION": "~4",
    "FUNCTIONS_WORKER_RUNTIME": "node",
    "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "DefaultEndpointsProtocol=https;AccountName=...",
    "WEBSITE_CONTENTSHARE": "workers-app-staging-9180",
    "WEBSITE_ENABLE_SYNC_UPDATE_SITE": "false",
    "WEBSITE_MOUNT_ENABLED": "1",
    "WEBSITE_NODE_DEFAULT_VERSION": "18",
    "WEBSITE_RUN_FROM_PACKAGE": "....",
    "FUNCTIONS_NODE_BLOCK_ON_ENTRY_POINT_ERROR": "true",
    "AzureWebJobsFeatureFlags": "EnableWorkerIndexing"
  },
  "ConnectionStrings": {}
}

host.json 配置

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensions": {
    "cosmosDB": {
      "connectionMode": "Gateway",
      "protocol": "Https"
    },
    "eventGrid": {
      "maxConcurrentCallsPerWorker": 1
    },
    "http": {
      "routePrefix": "",
      "maxOutstandingRequests": 200,
      "maxConcurrentRequests": 100,
      "dynamicThrottlesEnabled": true,
      "hsts": {
        "isEnabled": true,
        "maxAge": "10"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.0.0, 5.0.0)"
  }
}

疑问

MacOS与Linux环境的差异可能是什么?还需要排查哪些内容?


内容的提问来源于stack exchange,提问作者George E

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 20:12:43