79228815

Date: 2024-11-27 02:52:30
Score: 1
Natty:
Report link

For anyone who faced the same issue, I managed to resolve as following: Note Python 3.11 as latest for the moment

  1. Pin versions in requirements.txt. I think it is critical, as after that the driver started loading
    azure-functions
    pyodbc==5.1.0
    SQLAlchemy==2.0.35
  1. Build on Ubuntu. Not on Windows. YAML below
      # Agent VM image name
      vmImageName: 'ubuntu-latest'
      # Working Directory
      solutionDir: '$(System.DefaultWorkingDirectory)'
  
    
    stages:
    - stage: Build
      displayName: Build and publish
      jobs:
      - job: Build
        displayName: Build
        pool:
          vmImage: $(vmImageName)
        - task: UsePythonVersion@0
          inputs:
            versionSpec: ''3.11''
          displayName: 'Use Python '3.11''
    
        - task: CmdLine@2
          displayName: 'Install python libs'
          inputs:
            script: |
              pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
            workingDirectory: $(solutionDir)/
        - task: ArchiveFiles@2
          displayName: 'Archive Function'
          inputs:
            rootFolderOrFile: '$(solutionDir)'
            includeRootFolder: false
            archiveType: zip
            archiveFile: $(Build.ArtifactStagingDirectory)/drop/$(Build.BuildId).zip
            replaceExistingArchive: false
    
        - publish: $(Build.ArtifactStagingDirectory)/drop/$(Build.BuildId).zip
          artifact: EdmWebhooks
          displayName: publish function artefact
  1. Use "ODBC Driver 18 for SQL Server"
    sql_engine = create_engine("mssql+pyodbc://{user}:{password}@{server}/{database}?driver=ODBC Driver 18 for SQL Server".format(
                    user = os.environ["SQL.User"],
                    password = os.environ["SQL.Password"],
                    server = os.environ["SQL.Server"],
                    database = os.environ["SQL.Database"],
                ))
Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Dmitry