Azure / functions-action

Enable GitHub developers to deploy to Azure Function Apps using GitHub Actions
MIT License
156 stars 76 forks source link

Rust handler times out with an HTTP 500 #169

Closed alfredodeza closed 1 year ago

alfredodeza commented 1 year ago

Trying to deploy a Rust application to Azure Functions using GitHub Actions succeeds but after deployment, the requests time out with an HTTP 500.

The same code deploys correctly using Visual Studio Code with the Azure Functions extension.

This is the workflow file to replicate:

name: functions-action Deploy

on:
  workflow_dispatch:

env:
  AZURE_FUNCTIONAPP_NAME: demo-rust-alfredo # set this to your application's name, it has to be unique
  AZURE_FUNCTIONAPP_PACKAGE_PATH: '.'   # set this to the path to your web app project, defaults to the repository root

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
    - name: 'Checkout GitHub action'
      uses: actions/checkout@v2

    - name: Install with RustUp
      shell: bash
      run: curl https://sh.rustup.rs -sSf | sh -s -- -y
    - name: Install musl
      run: sudo apt-get install -y --no-install-recommends musl-tools

    - name: Add Target
      shell: bash
      run: rustup target add x86_64-unknown-linux-musl

    - name: Build release
      shell: bash
      run: |
       cargo build --release --target=x86_64-unknown-linux-musl
       cp target/x86_64-unknown-linux-musl/release/handler .

    - name: Copy handler to parent directory
      shell: bash
      run: cp target/x86_64-unknown-linux-musl/release/handler .

    - name: 'Run Azure Functions action'
      uses: Azure/functions-action@v1
      with:
        app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
        package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
        publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }}

The repository with a working example is https://github.com/alfredodeza/rust-azure-function

On Azure, these logs are observed when streaming the logs:

2023-02-17T14:38:52Z   [Information]   Host lock lease acquired by instance ID '000000000000000000000000FE2CB7EF'.
2023-02-17T14:40:02Z   [Error]   Final functionDispatcher state: Initializing. Initialization timed out and host is shutting down
2023-02-17T14:40:02Z   [Verbose]   Sending invocation id:06d724e1-3c0f-4cc1-8021-77f8b241a3e6
2023-02-17T14:40:02Z   [Verbose]   Forwarding httpTrigger invocation for function: 'token' invocationId: '06d724e1-3c0f-4cc1-8021-77f8b241a3e6'
2023-02-17T14:40:02Z   [Verbose]   Sending invocation for function: 'token' invocationId: '06d724e1-3c0f-4cc1-8021-77f8b241a3e6'
2023-02-17T14:40:02Z   [Error]   Executed 'Functions.token' (Failed, Id=06d724e1-3c0f-4cc1-8021-77f8b241a3e6, Duration=122085ms)

The only other way to deploy correctly was using Azure Core Tools with the func command.

The GitHub workflow file was then updated to install Azure Core Tools and deploy the same Rust application which succeeds using the following (excerpt from full markdown file):

    - name: Azure Login
      uses: azure/login@v1
      with:
         creds: ${{ secrets.AZURE_CREDENTIALS }}

    - name: Deploy to Azure Functions
      shell: bash
      run: func azure functionapp publish ${{ env.AZURE_FUNCTIONAPP_NAME }} --custom
github-actions[bot] commented 1 year ago

This issue is idle because it has been open for 14 days with no activity.

alfredodeza commented 1 year ago

This issue is very much active and still a concern. @patelchandni is there a way we can prevent the bot from flagging this one?

patelchandni commented 1 year ago

@alfredodeza it is either incorrect folder structure passed into this action or need to trigger remote build steps for this app (which may be core tool triggers by default). I think the app used in your pipeline no longer exists because of which I cannot further investigate. Please open a support ticket from Azure portal to investigate this further with a sample app ready.

alfredodeza commented 1 year ago

@patelchandni thanks for providing some information about what might be going on. The example repository has two workflows, one with the function-action which doesn't work (times out) and the other one with Azure Core Tools (as described in this ticket).

You can replicate this issue by creating an Azure Function and attempting to deploy with the sample workflow provided.

I wasn't able to open a ticket from the Azure Portal as this was considered a "code" issue that would require a support plan in place.

If you need me to create the Function App again, I can also do that. Happy to provide everything needed to get this solved!

patelchandni commented 1 year ago

Removing line 44: Update deploy.yml · alfredodeza/rust-azure-function@e0ddd59 (github.com) fixed the issue.