- Notifications
You must be signed in to change notification settings - Fork 85
Closed
Labels
Description
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 }} --customReactions are currently unavailable