"deploy function -f handle --stage dev" breaks function entirely


Working with AWS and C#.

I have a working Lambda function in two stages, dev and prod. Both work fine if I remove them and redeploy them entirely. However, obviously I don’t want to change my endpoint every time there’s a change, so I was trying to deploy just the function itself, and encountered a problem. Serverless tells me it packaged, uploaded, and successfully deployed the function, but when I try to invoke it, I get the following error:

"Could not find the specified handler assembly with the file name '/var/task/CsharpHandlers.dll' or '/var/task/CsharpHandlers.ni.dll'. The assembly should be located in the root of your uploaded .zip file."

I re-ran the build and tried again, same issue. Removed and redeployed and it works. Tried to update just the function again, same issue. I swear it worked before I separated things into stages, so I think it’s related to that. Google yields zero page results, so I’m either a member of the red team or a fool. Please enlighten me as to which.

My .yml below:

service: email-event

  name: aws
  runtime: dotnetcore1.0
    dev_SVCURL: "https://dev.mydomain.com/svc/api"
    prod_SVCURL: "https://app.mydomain.com/svc/api"

  artifact: bin/release/netcoreapp1.0/deploy-package.zip

    handler: CsharpHandlers::MyNamespace.EmailEvent.Handler::Handle
      - http: 
          path: endpoint
          method: post
          integration: lambda
              application/json: '{ "xApiKey": "$input.params(''x-api-key'')", "svcUrl": "${self:provider.environment.${opt:stage}_SVCURL}", "body": $input.json(''$'') }'

Hey @FacioRatio
This may help: https://github.com/serverless/serverless/issues/2946#issuecomment-280183207
So define the package artifact on function level, as well. Else serverless tries to package it for you when deploying a single function what’s not really applicable for C#, Java, …

Thank you for your response. I tried it (perhaps naively) this way:

    handler: <same as before>
      artifact: ${self:package.artifact}
    events: <same as before>

…but I get the same error as before.

Hmm, strange
Which commands are you executing?

Running serverless deploy multiple times should just work fine in your case and only update/upload your artifact package and changes (if any) in the cloudformation template serverless creates.
I’d rather not use the function deployment for C#, Java, …

I’m running:

serverless deploy -f handle --stage dev

It didn’t occur to me to just do:

serverless deploy --stage dev

…which is what you just implied I should do, and which did work. I don’t know whether the change to my .yml file is needed or not. Currently it’s in there, though.

Thanks! Guess I fell into the “fool” category this time.

Edit: removed, deployed without the ${self:package.artifact} line, and deployed again, and it all worked.