serverless / serverless-azure-functions

Serverless Azure Functions Plugin – Add Azure Functions support to the Serverless Framework
MIT License
266 stars 162 forks source link

Error when deploying linux funcapp node10/12 #437

Open grizzly-monkey opened 4 years ago

grizzly-monkey commented 4 years ago

This is a Bug Report

Yes

Description

When using azure function 1.0.2-23 to deploy functionApp with linux os node10/12 getting error.


Similar or dependent issues:

- #12345

## Additional Data
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              13.12.0
     Framework Version:         1.67.3
     Plugin Version:            3.6.6
     SDK Version:               2.3.0
     Components Version:        2.29.3

- **_Serverless Framework Version you're using_**: 1.67.3
- **_Serverless CLI Version you're using_**:
- **_Serverless Azure Plugin Version you're using_**: 1.0.2-23 
- **_Operating System_**:darwin
- **_Stack Trace_**:
- **_Provider Error messages_**:
tbarlow12 commented 4 years ago

@grizzly-monkey thanks for opening this issue. I just repro'd on my end and will start investigating

jeicob22 commented 4 years ago

Hello :)

I have the same issue here. Seems to be independent of the runtime, it crashes with that error when defining os: linux (tested on all nodejs and python runtimes)

tbarlow12 commented 4 years ago

Good to know. Syncing up with the Azure Functions team to see what changed

tbarlow12 commented 4 years ago

@jeicob22 I was able to deploy a python function fine. Maybe share your config and the exact error message?

jeicob22 commented 4 years ago

Sure, my serverless.yml file was:


# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
#    docs.serverless.com
#
# Happy Coding!

service: megatest-num2

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"

provider:
  name: azure
  location: West Europe
  region: westeurope
  runtime: nodejs12
  # runtime: "python3.7"
  os: "linux"
  resourceGroup: my-rg-name-jeicob22-rg
  environment:
    TEST_URL: 'https://mytest.online.local'

plugins: # look for additional plugins in the community plugins repo: https://github.com/serverless/plugins
  - serverless-azure-functions

# you can add packaging information here
package:
  # include:
  #   - include-me.js
  #   - include-me-dir/**
  exclude:
    # - exclude-me.js
    # - exclude-me-dir/**
    - local.settings.json
    - .vscode/**

functions:
  hello:
    handler: src/handlers/hello.sayHello
    # handler: src/handlerspython/hello.my_function
    events:
      - http: true
        x-azure-settings:
          methods:
            - GET
          authLevel: anonymous # can also be `function` or `admin`

Could be possible that I'm missing something. I'm relativelly new to Serverless framework.

Thanks @tbarlow12

grizzly-monkey commented 4 years ago

I have also opened case with Microsoft support team .. shared the generated SLS template with them . will keep the post updated once i hear something from them.

jeicob22 commented 4 years ago

Forgot to paste the error logs, sorry.

The plugin is installed locally in the ".serverless_plugins/" folder. Wish this helps. Many thanks!!

$ SLS_DEBUG=* sls deploy
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command remove
Serverless: Load command deploy
Serverless: Load command deploy:list
Serverless: Load command deploy:apim
Serverless: Load command func
Serverless: Load command func:add
Serverless: Load command func:remove
Serverless: Load command offline
Serverless: Load command offline:start
Serverless: Load command offline:build
Serverless: Load command offline:cleanup
Serverless: Load command rollback
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command dev
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Initializing provider configuration...
Serverless: Removing .serverless directory
Serverless: Parsing Azure Functions Bindings.json...
Serverless: Building binding for function: hello event: httpTrigger
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Logging into Azure
Serverless: Using subscription ID: xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx
Serverless: Creating resource group: my-rg-name-jeicob22-rg
Serverless: Creating function app: sls-weur-dev-megatest-num2
Serverless: -> Creating ARM template from type: consumption
Serverless: -> Merging environment configuration
Serverless: Listing deployments for resource group 'my-rg-name-jeicob22-rg':
Serverless: -> Deploying ARM template...
Serverless: ---> Resource Group: my-rg-name-jeicob22-rg
Serverless: ---> Deployment Name: slsweurdevmegatestnum2-DEPLOYMENT-t1587460668814
Serverless: Listing deployments for resource group 'my-rg-name-jeicob22-rg':

  Error --------------------------------------------------

  Error: DeploymentFailed - At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.------------------------
  DEPLOYMENT ERROR DETAILS
  ------------------------

  BadRequest - {
    "Code": "BadRequest",
    "Message": "The parameter LinuxFxVersion has an invalid value.",
    "Target": null,
    "Details": [
      {
        "Message": "The parameter LinuxFxVersion has an invalid value."
      },
      {
        "Code": "BadRequest"
      },
      {
        "ErrorEntity": {
          "ExtendedCode": "01007",
          "MessageTemplate": "The parameter {0} has an invalid value.",
          "Parameters": [
            "LinuxFxVersion"
          ],
          "Code": "BadRequest",
          "Message": "The parameter LinuxFxVersion has an invalid value."
        }
      }
    ],
    "Innererror": null
  }
      at ArmService.<anonymous> (/home/juribe/Documents/test-projects/azure-serverless/megatest-num2/.serverless_plugins/serverless-azure-functions/lib/services/armService.js:235:39)
      at step (/home/juribe/Documents/test-projects/azure-serverless/megatest-num2/.serverless_plugins/serverless-azure-functions/lib/services/armService.js:56:23)
      at Object.next (/home/juribe/Documents/test-projects/azure-serverless/megatest-num2/.serverless_plugins/serverless-azure-functions/lib/services/armService.js:37:53)
      at fulfilled (/home/juribe/Documents/test-projects/azure-serverless/megatest-num2/.serverless_plugins/serverless-azure-functions/lib/services/armService.js:28:58)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
  From previous event:
      at PluginManager.invoke (/snapshot/serverless/lib/classes/PluginManager.js:490:22)
      at /snapshot/serverless/lib/classes/PluginManager.js:525:24
  From previous event:
      at PluginManager.run (/snapshot/serverless/lib/classes/PluginManager.js:525:8)
      at /snapshot/serverless/lib/Serverless.js:133:33
      at processImmediate (internal/timers.js:456:21)
      at process.topLevelDomainCallback (domain.js:137:15)
  From previous event:
      at Serverless.run (/snapshot/serverless/lib/Serverless.js:120:74)
      at /snapshot/serverless/bin/serverless.js:82:30
      at /snapshot/serverless/node_modules/graceful-fs/graceful-fs.js:144:16
      at /snapshot/serverless/node_modules/graceful-fs/graceful-fs.js:65:14
      at FSReqCallback.oncomplete (fs.js:154:23)
  From previous event:
      at /snapshot/serverless/bin/serverless.js:82:8
      at processImmediate (internal/timers.js:456:21)
      at process.topLevelDomainCallback (domain.js:137:15)
  From previous event:
      at Object.<anonymous> (/snapshot/serverless/bin/serverless.js:71:4)
      at Module._compile (pkg/prelude/bootstrap.js:1324:22)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
      at Module.load (internal/modules/cjs/loader.js:1000:32)
      at Function.Module._load (internal/modules/cjs/loader.js:899:14)
      at Function.Module.runMain (pkg/prelude/bootstrap.js:1379:12)
      at internal/main/run_main_module.js:18:47

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              12.16.1
     Framework Version:         1.67.3 (standalone)
     Plugin Version:            3.6.6
     SDK Version:               2.3.0
     Components Version:        2.29.0
jeicob22 commented 4 years ago

I think I've found the root cause of the "bug" (I think this is more related to Azure instead of to the Plugin).

As I'm using an specific RG, if that RG already contains azure functions based on windows os, it crashes when trying to deploy python app (which strictly requires linux as exposed in this plugin documentation).

I've manually removed the existent "App Service Plan", redeployed, and everything started to work.

Hazhzeng commented 4 years ago

Hi @tbarlow22,

I think the generated Azure Resource Management template from https://github.com/serverless/serverless-azure-functions/blob/5ec4559817387d33b5e30e5cc06dedf2e9ae2ad0/src/armTemplates/resources/appServicePlan.ts#L52-L58 is a little bit off. In the properties field, it should include

"reserved": true // if it is Linux
"workerSize": "3" // the default number of workers when not scaledout