Azure python blob storage trigger run azure devops pipeline problem

현균 박 41 Reputation points


I'm having a hard time for many days because of this problem.

I made Azure blob trigger(using python) for run Azure Devops Pipelines.

but it doesn't work.

It's a my code.

   import logging  
   import base64  
   import http.client  
   import mimetypes  
   import azure.functions as func  
   from azure.devops.connection import Connection  
   from msrest.authentication import BasicAuthentication  
   import pprint  
   def main(myblob: func.InputStream):"Python blob trigger function processed blob \n"  
                    f"Name: {}\n"  
                    f"Blob Size: {myblob.length} bytes")  
       "start connect devops")  
       conn = http.client.HTTPSConnection("")  
       body = "{\"previewRun\":false,\"stageToSkip=\": [],\"resources\": [], \"templateParameters\": [], \"variables\": []}"  
       pt = 'xvfnonij*************************wifjellqzjiqwa'  
       message_bytes = pt.encode('ascii')  
       base64_bytes = base64.b64encode(message_bytes)  
       base64_pat = base64_bytes.decode('ascii')"pat: " + base64_pat)  
       headers = {  
           'Content-Type' : 'application/json',  
           'Accept' : 'application/json',  
           'Authorization' : 'Basic '+ base64_pat  
   "try connect devops")  
       url = "/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=6.0-preview.1""POST", url, body, headers=headers))  
       res = conn.getresponse()  
       data ="finish connect devops")  

I checked few links for this work.

but my code's response was just 302 message.

I think.. 302 response is my oauth problem. however i used my PAT code from azure devops. also convert by base64.

Could you please let me know what the problem is?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,637 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pramod Valavala 20,611 Reputation points Microsoft Employee

    anonymous user A 302 response indicates a redirect. By default, the http.client doesn't follow redirects I believe but using a package like requests should do the trick.

1 additional answer

Sort by: Most helpful
  1. Vinay 1 Reputation point

    Kindly please share the working Code please. That will be helpfull. Please Share working code to this Mailid : theproblemslover8@Stuff .com or else share here only please.

    0 comments No comments