By using Visual studio I deployed my python code as the deployment was successful But there is no link generated and also I cant see my deployment in my function app as in output terminal I can see
Http trigger are not found
The below code does is reads files from azure storage container and print the content in the file as output
As below is small portion of code but facing the same issue deployemnt successful and no http trigger found no link generated
Code:
import logging
import azure.functions as func
from azure.identity import ClientSecretCredential
from azure.storage.blob import BlobServiceClient
from dotenv import load_dotenv
import os
# Load environment variables from .env file
load_dotenv()
client_id = os.environ['AZURE_CLIENT_ID']
tenant_id = os.environ['AZURE_TENANT_ID']
client_secret = os.environ['AZURE_CLIENT_SECRET']
account_url = os.environ["AZURE_STORAGE_URL"]
# Create a credential
credentials = ClientSecretCredential(
client_id=client_id,
client_secret=client_secret,
tenant_id=tenant_id
)
def list_blob():
container_name = 'prudhvicontainer'
# Set client to access Azure storage container
blob_service_client = BlobServiceClient(account_url=account_url, credential=credentials)
# Get the container client
container_client = blob_service_client.get_container_client(container=container_name)
blob_names = []
for blob in container_client.list_blobs():
blob_names.append(blob.name)
return blob_names
def get_multi_blob_data():
container_name = 'prudhvicontainer'
# Set client to access Azure storage container
blob_service_client = BlobServiceClient(account_url=account_url, credential=credentials)
# Get the container client
container_client = blob_service_client.get_container_client(container=container_name)
blob_data = {}
for blob in container_client.list_blobs():
blob_client = container_client.get_blob_client(blob=blob.name)
data = blob_client.download_blob().readall()
blob_data[blob.name] = data.decode("utf-8")
return blob_data
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
action = req.params.get('action')
if not action:
try:
req_body = req.get_json()
except ValueError:
pass
else:
action = req_body.get('action')
if action == 'list':
blob_names = list_blob()
return func.HttpResponse(str(blob_names), status_code=200)
elif action == 'get':
blob_data = get_multi_blob_data()
return func.HttpResponse(str(blob_data), status_code=200)
else:
return func.HttpResponse(
"Please pass a valid action on the query string or in the request body. Valid actions are 'list' and 'get'.",
status_code=400
)
The packages i used
azure.identity
azure.storage.blob
import load_dotenv
import os
import openai
import pyodbc
import pandas as pd
import StringIO
import sqlparse
requiremnts.txt has
annotated-types==0.7.0
anyio==4.4.0
azure-core==1.30.2
azure-functions==1.20.0
azure-identity==1.17.1
azure-storage-blob==12.20.0
certifi==2024.7.4
cffi==1.16.0
charset-normalizer==3.3.2
colorama==0.4.6
cryptography==42.0.8
distro==1.9.0
h11==0.14.0
httpcore==1.0.5
httpx==0.27.0
idna==3.7
isodate==0.6.1
msal==1.29.0
msal-extensions==1.2.0
numpy==2.0.0
openai==1.35.14
pandas==2.2.2
portalocker==2.10.1
pycparser==2.22
pydantic==2.8.2
pydantic_core==2.20.1
PyJWT==2.8.0
pyodbc==5.1.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pytz==2024.1
requests==2.32.3
six==1.16.0
sniffio==1.3.1
sqlparse==0.5.1
tqdm==4.66.4
typing_extensions==4.12.2
tzdata==2024.1
urllib3==2.2.2
# Windows-specific dependencies
pywin32==306; platform_system == "Windows"
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
"AZURE_CLIENT_ID": " ",
"AZURE_TENANT_ID": " ",
"AZURE_CLIENT_SECRET": " ",
"AZURE_STORAGE_URL": ,
"AZURE_OPENAI_API_KEY":
}
}
host.json :
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
output :
12:39:50 PM PrudhviAPI: Syncing triggers...
12:39:55 PM PrudhviAPI: Querying triggers...
12:39:59 PM PrudhviAPI: Uploading settings...
12:39:59 PM: Ignored the following settings that were already the same:
- FUNCTIONS_WORKER_RUNTIME
- AzureWebJobsFeatureFlags
- AZURE_CLIENT_ID
- AZURE_TENANT_ID
- AZURE_CLIENT_SECRET
- AZURE_STORAGE_URL
- AZURE_OPENAI_API_KEY
12:39:59 PM: WARNING: This operation will not delete any settings in "PrudhviAPI". You must manually delete settings if desired.
12:39:59 PM: Excluded the following settings:
- AzureWebJobsStorage
12:39:59 PM PrudhviAPI: No HTTP triggers found.
12:40:00 PM PrudhviAPI: Successfully uploaded settings.
Bandaru Prudhvi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
- Before the deployment, add the Environment variables in function app.
- Add the correct packages in requirements.txt file.
annotated-types==0.7.0
anyio==4.4.0
azure-core==1.30.2
azure-functions==1.20.0
azure-identity==1.17.1
azure-storage-blob==12.20.0
certifi==2024.7.4
cffi==1.16.0
charset-normalizer==3.3.2
colorama==0.4.6
cryptography==42.0.8
distro==1.9.0
h11==0.14.0
httpcore==1.0.5
httpx==0.27.0
idna==3.7
isodate==0.6.1
msal==1.29.0
msal-extensions==1.2.0
numpy==2.0.0
openai==1.35.14
pandas==2.2.2
portalocker==2.10.1
pycparser==2.22
pydantic==2.8.2
pydantic-core==2.20.1
PyJWT==2.8.0
pyodbc==5.1.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pytz==2024.1
requests==2.32.3
six==1.16.0
sniffio==1.3.1
sqlparse==0.5.1
tqdm==4.66.4
typing-extensions==4.12.2
tzdata==2024.1
urllib3==2.2.2
# Windows-specific dependencies
pywin32==306; platform_system == "Windows"
- I have done few modifications to your code which is give below.
import azure.functions as func
import logging
from azure.identity import ClientSecretCredential
from azure.storage.blob import BlobServiceClient
import os
client_id = os.environ['AZURE_CLIENT_ID']
tenant_id = os.environ['AZURE_TENANT_ID']
client_secret = os.environ['AZURE_CLIENT_SECRET']
account_url = os.environ["AZURE_STORAGE_URL"]
credentials = ClientSecretCredential(
tenant_id=tenant_id,
client_id=client_id,
client_secret=client_secret
)
def list_blob():
container_name = 'sample-container'
blob_service_client = BlobServiceClient(account_url=account_url, credential=credentials)
container_client = blob_service_client.get_container_client(container=container_name)
blob_names = []
for blob in container_client.list_blobs():
blob_names.append(blob.name)
return blob_names
def get_multi_blob_data():
container_name = 'sample-container'
blob_service_client = BlobServiceClient(account_url=account_url, credential=credentials)
container_client = blob_service_client.get_container_client(container=container_name)
blob_data = {}
for blob in container_client.list_blobs():
blob_client = container_client.get_blob_client(blob=blob.name)
data = blob_client.download_blob().readall()
blob_data[blob.name] = data.decode("utf-8")
return blob_data
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@app.function_name(name="HttpTrigger1")
@app.route(route="main")
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
action = req.params.get('action')
if not action:
try:
req_body = req.get_json()
except ValueError:
pass
else:
action = req_body.get('action')
if action == 'list':
blob_names = list_blob()
return func.HttpResponse(str(blob_names), status_code=200)
elif action == 'get':
blob_data = get_multi_blob_data()
return func.HttpResponse(str(blob_data), status_code=200)
else:
return func.HttpResponse(
"Please pass a valid action on the query string or in the request body. Valid actions are 'list' and 'get'.",
status_code=400
)
- Got the endpoints post deployment.