Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
331 stars 100 forks source link

Deploying via github actions not working, all files other than the functions_app.py file being shown within app portal #1428

Closed TylerMcCarthyGitHub closed 4 months ago

TylerMcCarthyGitHub commented 4 months ago

Investigative information

Please provide the following:

Repro steps

Provide the steps required to reproduce the problem: using main.yaml file push latest changes to github and actions will deploy to azure.

Expected behavior

Provide a description of the expected behavior.

Actions succeeds to deploy to azure but upon inspection of the azure functions app there are no functions present and also only app files present (not in .gitignore) are all but the .py file.

Contents of the requirements.txt file:

azure-ai-formrecognizer==3.3.2 azure-common==1.1.28 azure-core==1.30.0 certifi==2024.2.2 charset-normalizer==3.3.2 idna==3.6 isodate==0.6.1 msrest==0.7.1 oauthlib==3.2.2 requests==2.31.0 requests-oauthlib==1.3.1 six==1.16.0 typing_extensions==4.9.0 urllib3==2.2.0

Related information

```yaml # main.yaml name: CI/CD Pipeline on: push: branches: - main paths-ignore: - 'README.md' # Ignore workflow run if only README.md is changed. jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.10' - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Lint with flake8 run: | flake8 . - name: Deploy to Azure uses: azure/functions-action@v1 with: app-name: smartFormAIFunctions package: . publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} ``` ```python # __init__.py import logging import os import azure.functions as func from azure.core.credentials import AzureKeyCredential from azure.ai.documentintelligence import DocumentIntelligenceClient from .feature_extraction import extract_section_headers def main(req: func.HttpRequest) -> func.HttpResponse: logging.info('Python HTTP trigger function processed a request.') document_url = req.params.get('documentUrl') if not document_url: try: req_body = req.get_json() document_url = req_body.get('documentUrl') except ValueError: pass if not document_url: return func.HttpResponse( "Please pass a document URL in the query string or in the " "request body", status_code=400 ) # Azure credentials from environment variables endpoint = os.environ["DOCUMENT_INTELLIGENCE_ENDPOINT"] key = os.environ["DOCUMENT_INTELLIGENCE_KEY"] credential = AzureKeyCredential(key) document_intelligence_client = DocumentIntelligenceClient( endpoint=endpoint, credential=credential ) try: poller = document_intelligence_client.begin_analyze_document_from_url( "prebuilt-layout", document_url) result = poller.result() print(result) # Extract section headers section_headers = extract_section_headers(result) return func.HttpResponse( body=str(section_headers), mimetype="application/json", status_code=200 ) except Exception as e: return func.HttpResponse( f"Failed to analyze document. Exception: {str(e)}", status_code=500 ) ``` ```json { "IsEncrypted": false, "Values": { "FUNCTIONS_WORKER_RUNTIME": "python", "DOCUMENT_INTELLIGENCE_ENDPOINT": "https://smartformprocessor.cognitiveservices.azure.com/", "DOCUMENT_INTELLIGENCE_KEY": "861e665469694f99acc152609d367628" }, "AzureWebJobsFeatureFlags": "EnableWorkerIndexing" } ```
hallvictoria commented 4 months ago

Hi @TylerMcCarthyGitHub,

Seems that there might be an issue in your __init__.py file. Are you able to run the function locally? What are the issues you're getting with Core Tools?

Also, do you have azure-functions and azure-ai-documentintelligence in your req.txt file? It looks like they're being imported in the function app but not listed in the req.txt contents provided.

microsoft-github-policy-service[bot] commented 4 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.