serverless / serverless-azure-functions

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

Sls deploy doesn't deploy recent changes to Azure from github actions #562

Open mzubova opened 3 years ago

mzubova commented 3 years ago

This is a Bug Report

Description

When I make a sls deployment to Azure by means of github actions (new functions or changes in existing ones), my changes don't get deployed (although I don't see any errors or anything weird in the logs). When I do sls deploy locally - it all works just fine.

Here's an example of my github action:

name: Serverless Deploy to DEV
on: 
  push:
   branches:
     - main
  workflow_dispatch: 

jobs:
  sls-deploy:
    name: Deploy Serverless App
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        ref: main
        fetch-depth: 0

    - uses: actions/setup-node@v1
      with:
        node-version: '14.x'

    - name: Create env file
      run: |
        cat > .env << EOF
        ${{ secrets.ENV }}
        EOF

    - name: Install Serverless Framework
      run: npm install -g serverless

    - name: npm install
      run: npm install

    - name: serverless deploy
      uses: serverless/github-action@master
      with:
        args: deploy
      env:   
          AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
          AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
          AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
          AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
          AZURE_DEV_RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }}  

And that's the serverless.yaml:

service: my-service

frameworkVersion: "2"

provider:
  name: azure
  region: West Europe
  runtime: nodejs12
  resourceGroup: resourceGroup
  subscriptionId: subscriptionId
  stage: dev
  tags:
    Application: Azure Infrastructure
    CostCenter: A0300770
    Environment: Development

  apim:
    apis:
      - name: my-api
        subscriptionRequired: false
        displayName: My API
        description: My API
        protocols:
          - https
        path: /
        authorization: none
    cors:
      allowCredentials: false
      allowedOrigins:
        - "*"
      allowedMethods:
        - GET
        - POST
        - PUT
        - DELETE
        - PATCH
      allowedHeaders:
        - "*"
      exposeHeaders:
        - "*"

plugins:
  - serverless-azure-functions
  - serverless-dotenv-plugin

package:
  patterns:
    - "!local.settings.json"
    - "!.gitignore"
    - "!.env"
    - "!tmp/**"
    - "!.git/**"
    - "!.vscode/**"

functions:
  # Stuff
  getSwagger:
    handler: src/handlers/swagger
    events:
      - http: true
        x-azure-settings:
          methods:
            - get
          route: v1/swagger.yaml

I've checked forums and places, and my configs don't look that very different from the examples. Could you please kindly advice on what can be wrong and which settings (maybe in Azure) I need to look into?

mzubova commented 3 years ago

Small update: was able to reproduce the issue locally without github actions.

When deploying an app using service principle account, no changes appear for the function app (although I can see a package in deployment artifacts). Same operation but using my own account - and it all works just fine. Both sp and my account have the same permissions.

Also, if to delete both function app and app service plan, it is being recreated with my account but fails with sp:


Serverless: {"error":{"code":"ResourceNotFound","message":"The Resource 'Microsoft.Web/sites/***' under resource group '***' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"}}

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

  Error: 'functionApp' cannot be null or undefined
      at Function.Guard.null (/Users/maria.zubova/Projects/***i/node_modules/serverless-azure-functions/lib/shared/guard.js:27:19) ```