node.jsazureazure-functionsazure-functions-node.js

Azure functions disappearing from app when changing computers


I recently changed from an Unbuntu to a MacOS laptop and I seem to be having issues in deploying an nodejs azure function app from it.

I just cloned the repo and loved the local.settings.json file to the MacOS computer but whenever I run func azure functionapp publish workers-app-staging from the MacOS it fails to deploy, the only thing I get is this then the cli exists

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:

On the other side, running the same command from Linux works as expected and the cli prints out in the terminal all the functions in the project on top of the output above. The functions get deployed and I can see them in the Azure Portal.

There is no failure log, the zip file gets updated in the bucket and the WEBSITE_RUN_FROM_PACKAGE env gets updated with the correct string. (The Azure Func app is linux consumption)

Any Idea what would be the difference between the two? What should I be looking into more to debug this?

Tried debugging and tweaking the settings and making sure the configs are the same between the linux and the macos machine

I have the following versions

❯ 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

Function code

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": {}
}

hosts.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)"
  }
}

Solution

  • Found the issue after digging into the "Diagnose and solve problem" section of the Azure Portal, specifically to the "Functions that are not triggering" utility, as the functions were deployed just the bindings not synced.

    The error was pointing at one of the functions not being able to load due to the argon2 package which according to this answer needed a different command to install on MacOS. After running it the functions deployed correctly