Python приложения-функции Azure — доступ к учетной записи храненияPython

Программы на Python
Anonymous
 Python приложения-функции Azure — доступ к учетной записи хранения

Сообщение Anonymous »

Я создал приложение-функцию на хосте Linux. Я развертываю через конвейер, и все работает как положено. Пока я не начну импортировать библиотеки Azure, функции просто не развернутся. Никаких ошибок.
#When adding below functions fails to show in the azure portal.
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient

Полный код:
import logging
import azure.functions as func
import json
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient

app = func.FunctionApp()

import logging
import azure.functions as func

app = func.FunctionApp()

@app.route(route="get_port_data", auth_level=func.AuthLevel.FUNCTION)
def get_port_data(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')

lat = req.params.get('lat')
long = req.params.get('lng')

# credential = DefaultAzureCredential()
# blob_service_client = BlobServiceClient(account_url="https://xx.blob.core.windows.net", credential=credential)

jsn = {"region":"USAC","port":"West"}

return func.HttpResponse(
json.dumps(jsn),
mimetype="application/json",
status_code=200
)

Deployment pipeline:

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- none

variables:
# Azure Resource Manager connection created during pipeline creation
azureServiceConnectionId: 'xx'

# Web app name
webAppName: 'xx'

# Agent VM image name
vmImageName: 'ubuntu-latest'

# Environment name
environmentName: 'func-xx'

# Project root folder.
projectRoot: $(System.DefaultWorkingDirectory)

# Python version: 3.11. Change this to match the Python runtime version running on your web app.
pythonVersion: '3.11'

workingDirectory: ''

pool:
vmImage: $(vmImageName)

stages:
- stage: Build
displayName: Build stage

jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)

steps:
# - bash: |
# if [ -f extensions.csproj ]
# then
# dotnet build extensions.csproj --runtime ubuntu.16.04-x64 --output ./bin
# fi
# workingDirectory: $(workingDirectory)
# displayName: 'Build extensions'

- task: UsePythonVersion@0
displayName: 'Use Python 3.11'
inputs:
versionSpec: 3.11

- bash: |
pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
workingDirectory: $(workingDirectory)
displayName: 'Install application dependencies'

- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(workingDirectory)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true

- publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()

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

strategy:
runOnce:
deploy:

steps:
- task: AzureFunctionApp@1
displayName: 'Azure functions app deploy'
inputs:
azureSubscription: '$(azureServiceConnectionId)'
appType: functionAppLinux
appName: $(webAppName)
package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'


Подробнее здесь: https://stackoverflow.com/questions/788 ... ge-account

Вернуться в «Python»