Hi.
I made Azure blob trigger(using python) for run Azure Devops Pipelines.
If I run this trigger on local, it will run without any problems.
However, if I deploy the trigger as Azure portal and use it, an unknown reason will be returned.
Error
2021-03-19T00:54:58Z [Information] Trigger Details: MessageId: b34a8eb6-3797-4841-9a18-09a66547748f, DequeueCount: 1, InsertionTime: 2021-03-19T00:54:58.000+00:00, BlobCreated: 2021-03-19T00:54:56.000+00:00, BlobLastModified: 2021-03-19T00:54:56.000+00:00
2021-03-19T00:54:58Z [Verbose] Sending invocation id:1c3a7ca1-33ed-4ed1-83d2-2d38006ab462
2021-03-19T00:54:58Z [Verbose] Posting invocation id:1c3a7ca1-33ed-4ed1-83d2-2d38006ab462 on workerId:fa454cb8-b237-4c2f-b818-67197b8472a7
2021-03-19T00:54:58Z [Error] Executed 'Functions.BlobTriggerDevopsPipeline' (Failed, Id=1c3a7ca1-33ed-4ed1-83d2-2d38006ab462, Duration=79ms)
2021-03-19T00:54:59Z [Information] Executing 'Functions.BlobTriggerDevopsPipeline' (Reason='New blob detected: azureml-blobstore-5d7dd05e-c52c-4f52-b835-37179dea8ba8/training-data/data.txt', Id=98cc96c5-2b74-4acf-934d-89eac9ad9599)
2021-03-19T00:54:59Z [Information] Trigger Details: MessageId: b34a8eb6-3797-4841-9a18-09a66547748f, DequeueCount: 2, InsertionTime: 2021-03-19T00:54:58.000+00:00, BlobCreated: 2021-03-19T00:54:56.000+00:00, BlobLastModified: 2021-03-19T00:54:56.000+00:00
2021-03-19T00:54:59Z [Verbose] Sending invocation id:98cc96c5-2b74-4acf-934d-89eac9ad9599
2021-03-19T00:54:59Z [Verbose] Posting invocation id:98cc96c5-2b74-4acf-934d-89eac9ad9599 on workerId:fa454cb8-b237-4c2f-b818-67197b8472a7
2021-03-19T00:54:59Z [Error] Executed 'Functions.BlobTriggerDevopsPipeline' (Failed, Id=98cc96c5-2b74-4acf-934d-89eac9ad9599, Duration=22ms)
2021-03-19T00:54:59Z [Information] Executing 'Functions.BlobTriggerDevopsPipeline' (Reason='New blob detected: azureml-blobstore-5d7dd05e-c52c-4f52-b835-37179dea8ba8/training-data/data.txt', Id=978ce53f-2917-41c0-855c-9f33cdc54446)
2021-03-19T00:54:59Z [Information] Trigger Details: MessageId: b34a8eb6-3797-4841-9a18-09a66547748f, DequeueCount: 3, InsertionTime: 2021-03-19T00:54:58.000+00:00, BlobCreated: 2021-03-19T00:54:56.000+00:00, BlobLastModified: 2021-03-19T00:54:56.000+00:00
and... my codes
init.py
import logging
import base64
import requests
import azure.functions as func
# from azure.devops.connection import Connection
# from msrest.authentication import BasicAuthentication
def main(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n"
f"Blob Size: {myblob.length} bytes")
logging.info(f"start connect devops")
pt = ':' + '[PAT CODE]'
base64_pat = base64.b64encode(pt.encode('ascii')).decode('ascii')
logging.info('encoding result : ' + base64_pat)
headers = {
'Content-Type' : 'application/json',
'Accept' : 'application/json',
'Authorization' : 'Basic '+ base64_pat
}
body = "{\r\n \"resources\": {\r\n \"repositories\": {\r\n \"self\": {\r\n \"refName\": \"master\"\r\n }\r\n }\r\n }\r\n}"
url = "https://dev.azure.com/devopscallfunc/HandsOn-CIC-TEST-Project/_apis/pipelines/3/runs?api-version=6.0-preview.1"
response = requests.request("POST", url, headers=headers, data = body)
logging.info(response.text.encode('utf8'))
logging.info(f"finish connect devops")
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}
Do you know why this trigger failed?