I am able to reproduce your issue:


And I can fix this issue:

I know what you are doing. Create virtual environment, active virtual environment, install python packages to the virtual environment...
And you mentioned VS Code/CLI deploy is no problem.
Yes, as you observe, everything should be installed successfully to the virtual environment.
So Why?
The reason is both of VS Code Deploy and CLI deploy doesn't have any relationship with virtual environment, these deployment method only care the requirements.txt file, they don't check others.
And, those operations you done is only work on current agent machine, azure function app you deploy to is another situation. It is a new machine, a new environment.
So you just need to simply design the pipeline like this:
trigger:
- none
pool:
VMAS
steps:
- task: AzurePowerShell@5
inputs:
azureSubscription: 'testbowman_in_AAD'
ScriptType: 'InlineScript'
Inline: 'func azure functionapp publish <Your FunctionApp Name> --build remote'
azurePowerShellVersion: 'LatestVersion'
Working principle of VS Code and CLI
https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=asgi%2Capplication-level#remote-build
By default, Azure Functions Core Tools requests a remote build when
you use the following func azure functionapp publish command to
publish your Python project to Azure. Replace <APP_NAME> with the name
of your function app in Azure.
The Azure Functions extension for Visual Studio Code also requests a
remote build by default.