Hello,
I set up a CICD pipeline to handle deploying python code to the App Service but get this screen
![User's image](https://learn-attachment.microsoft.com/api/attachments/60058540-c60b-4822-8dfa-2637ca52d3b8?platform=QnA)
In the console it says "Failed to load resource: the server responded with a status of 503 (Service Unavailable)"
When I look in the logs, the main error says "ModuleNotFoundError: No module named 'uvicorn'". According to the docs this type of error happens when a virtual environment is also deployed. I did that at first but removed the line to create a virtual environment in my pipeline file (shown below) but the error still persists, I made a fresh app running the pipeline without creating a new virtual environment and the error still persists.
My app settings has SCM_DO_BUILD_DURING_DEPLOYMENT set to 1 as mentioned on the docs but it is still not working
![User's image](https://learn-attachment.microsoft.com/api/attachments/bc2879ed-9dda-45f6-81d0-1136d8e6171d?platform=QnA)
My wwwroot folder
![User's image](https://learn-attachment.microsoft.com/api/attachments/6a2f9bef-9be1-4ad7-9777-7b75fbbfee4c?platform=QnA)
The logs
2024-05-25T15:32:29.530049885Z _____
2024-05-25T15:32:29.530085985Z / _ \ __________ _________ ____
2024-05-25T15:32:29.530108485Z / /_\ \\___ / | \_ __ \_/ __ \
2024-05-25T15:32:29.530112385Z / | \/ /| | /| | \/\ ___/
2024-05-25T15:32:29.530115585Z \____|__ /_____ \____/ |__| \___ >
2024-05-25T15:32:29.530119085Z \/ \/ \/
2024-05-25T15:32:29.530122285Z A P P S E R V I C E O N L I N U X
2024-05-25T15:32:29.530125385Z
2024-05-25T15:32:29.530128285Z Documentation: http://aka.ms/webapp-linux
2024-05-25T15:32:29.530147085Z Python 3.12.2
2024-05-25T15:32:29.530150085Z Note: Any data outside '/home' is not persisted
2024-05-25T15:32:31.826079978Z Starting OpenBSD Secure Shell server: sshd.
2024-05-25T15:32:31.982245355Z Site's appCommandLine: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:api
2024-05-25T15:32:31.990065699Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -userStartupCommand 'gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:api'
2024-05-25T15:32:32.098018323Z Could not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2024-05-25T15:32:32.098059122Z Could not find operation ID in manifest. Generating an operation id...
2024-05-25T15:32:32.105534069Z Build Operation ID: 9409a21f-8457-436a-baca-bfe4afa14977
2024-05-25T15:32:32.592525967Z Oryx Version: 0.2.20240319.4, Commit: 350bad7f37fa55a2d965474e7e95f9075e989e10, ReleaseTagName: 20240319.4
2024-05-25T15:32:32.600564210Z Writing output script to '/opt/startup/startup.sh'
2024-05-25T15:32:32.741688495Z WARNING: Could not find virtual environment directory /home/site/wwwroot/antenv.
2024-05-25T15:32:32.741749595Z WARNING: Could not find package directory /home/site/wwwroot/__oryx_packages__.
2024-05-25T15:32:34.363265237Z
2024-05-25T15:32:34.363307036Z Error: class uri 'uvicorn.workers.UvicornWorker' invalid or not found:
2024-05-25T15:32:34.363336536Z
2024-05-25T15:32:34.363341136Z [Traceback (most recent call last):
2024-05-25T15:32:34.363344436Z File "/opt/python/3.12.2/lib/python3.12/site-packages/gunicorn/util.py", line 111, in load_class
2024-05-25T15:32:34.363347936Z mod = importlib.import_module('.'.join(components))
2024-05-25T15:32:34.363351236Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-25T15:32:34.363354636Z File "/opt/python/3.12.2/lib/python3.12/importlib/__init__.py", line 90, in import_module
2024-05-25T15:32:34.363374136Z return _bootstrap._gcd_import(name[level:], package, level)
2024-05-25T15:32:34.363377136Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-25T15:32:34.363380236Z File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
2024-05-25T15:32:34.363395836Z File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
2024-05-25T15:32:34.363399736Z File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
2024-05-25T15:32:34.363402836Z File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
2024-05-25T15:32:34.363405836Z File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
2024-05-25T15:32:34.363408836Z File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
2024-05-25T15:32:34.363411936Z File "<frozen importlib._bootstrap>", line 1324, in _find_and_load_unlocked
2024-05-25T15:32:34.363414935Z ModuleNotFoundError: No module named 'uvicorn'
2024-05-25T15:32:34.363417935Z ]
2024-05-25T15:32:34.370727983Z
The pipeline code:
stages:
- stage: Build
displayName: Build Stage
jobs:
- job: BuildJob
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(pythonVersion)' #using python 3.12
displayName: 'Use Python $(pythonVersion)'
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(projectRoot)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArchifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- publish: $(Build.ArchifactStagingDirectory)/$(Build.BuildId).zip
displayName: 'Upload Package'
artifact: drop
- stage: Deploy
displayName: 'Deploy Web App'
dependsOn: Build
condition: succeeded()
jobs:
- deployment: DeploymentJob
pool:
vmImage: $(vmImageName)
environment: $(environmentName)
strategy:
runOnce:
deploy:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(pythonVersion)'
displayName: 'Use Python $(pythonVersion)'
- task: AzureWebApp@1
displayName: 'Deploy to Azure Web App'
inputs:
appType: webapp
azureSubscription: $(azureServiceConnectionId)
appName: $(webAppName)
package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
Even when I try to install uvicorn directly through the startup command it still fails. I'm using FastAPI, uvicorn, and gunicorn on linux machine. Please advise.