Issues with Azure Pipelines for Deploying GStreamer to Azure Function App (Linux)

68 Views Asked by At

I'm currently working on a project where I need to integrate the Azure Speech SDK with GStreamer on a Function App (Linux environment). My primary goal is to utilize GStreamer for audio processing in conjunction with the Azure Speech SDK for speech-to-text capabilities. However, I'm encountering challenges in setting up GStreamer correctly to ensure it works seamlessly with the Speech SDK.

I am deploying the Function App using Azure Pipelines, installing the GStreamer libraries in the process:

    - bash: |
        python -m venv venv
        source venv/bin/activate
        pip install --target="$(workingDirectory)/.python_packages/lib/site-packages" -r requirements.txt
        pip list
      workingDirectory: $(workingDirectory)
      displayName: 'Install application dependencies'
          
    - script: |
        sudo apt-get update
        sudo apt-get install libgstreamer1.0-0 libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
      displayName: 'Install GStreamer'

followed by

  jobs:
  - deployment: Deploy
    displayName: Deploy
    environment: 'development'
    pool:
      vmImage: $(vmImageName)
    strategy:
      runOnce:
        deploy:

          steps:
          - task: AzureFunctionApp@1
            displayName: 'Azure functions app deploy'
            inputs:
              azureSubscription: '$(azureSubscription)'
              appType: functionAppLinux
              appName: $(functionAppName)
              package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
              deploymentMethod: 'zipDeploy'
              appSettings: 
          - script: |
              sudo apt-get update
              sudo apt-get install libunwind-dev libgstreamer1.0-0 libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
            displayName: 'Install GStreamer'

However, it seems that GStreamer is not deployed to the Function App itself as I am unable to find it using SSH (gst-launch-1.0) and get the following error when executing my function:

Error processing the request: Exception with error code: \n[CALL STACK BEGIN]\n\n/home/site/wwwroot/.python_packages/lib/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x18b2e1) [0x75f9b60202e1]\n/home/site/wwwroot/.python_packages/lib/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x140af7) [0x75f9b5fd5af7]\n/home/site/wwwroot/.python_packages/lib/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1f945e) [0x75f9b608e45e]\n/home/site/wwwroot/.python_packages/lib/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x13e5a9) [0x75f9b5fd35a9]\n/home/site/wwwroot/.python_packages/lib/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x216d8a) [0x75f9b60abd8a]\n/home/site/wwwroot/.python_packages/lib/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(recognizer_create_speech_recognizer_from_config+0x10b) [0x75f9b5f538fd]\n/usr/lib/x86_64-linux-gnu/libffi.so.7(+0x6d1d) [0x75f9d40a2d1d]\n/usr/lib/x86_64-linux-gnu/libffi.so.7(+0x6289) [0x75f9d40a2289]\n/usr/local/lib/python3.10/lib-dynload/_ctypes.cpython-310-x86_64-linux-gnu.so(+0xd97a) [0x75f9ddd2797a]\n/usr/local/lib/python3.10/lib-dynload/_ctypes.cpython-310-x86_64-linux-gnu.so(+0xe076) [0x75f9ddd28076]\n/usr/local/bin/../lib/libpython3.10.so.1.0(_PyObject_Call+0x5c) [0x75f9df1cfb0c]\n/usr/local/bin/../lib/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x1f11) [0x75f9df1c13f1]\n/usr/local/bin/../lib/libpython3.10.so.1.0(+0x165c41) [0x75f9df1bec41]\n/usr/local/bin/../lib/libpython3.10.so.1.0(PyVectorcall_Call+0xc5) [0x75f9df21c025]\n/usr/local/bin/../lib/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x1f11) [0x75f9df1c13f1]\n/usr/local/bin/../lib/libpython3.10.so.1.0(+0x165c41) [0x75f9df1bec41]\n/usr/local/bin/../lib/libpython3.10.so.1.0(_PyObject_FastCallDictTstate+0x12d) [0x75f9df1c596d]\n[CALL STACK END]\n\nException with an error code: 0x29 (SPXERR_GSTREAMER_NOT_FOUND_ERROR)

The function works perfectly fine locally with GStreamer installed, but fails once deployed to the function app.

Any help would be much appreciated!

1

There are 1 best solutions below

2
Bright Ran-MSFT On

The following step in your pipeline is just installing the GStreamer packages to the agent machine, and it will not install the packages to the function app on Azure.

- script: |
    sudo apt-get update
    sudo apt-get install libunwind-dev libgstreamer1.0-0 libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
  displayName: 'Install GStreamer'

You need to install all the required packages into the directory "$(System.DefaultWorkingDirectory)/.python_packages/lib/site-packages", and then archive this directory together with the source files of function app to a ZIP file. Then in the deploy job, deploy the ZIP file to Azure Function App.

For more details, you can reference the documentation "Build and deploy using Azure Pipelines".