I am Getting SSLError(SSLEOFError) error while triggering Azure DevOps pipeline from Databricks

sparmar
New Contributor

While triggering Azure devOps pipleline from Databricks, I am getting below error:

An error occurred: HTTPSConnectionPool(host='dev.azure.com', port=443): Max retries exceeded with url: /XXX-devops/XXXDevOps/_apis/pipelines/20250224.1/runs?api-version=7.1-preview.1 (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1147)'))).

I have confirmed that there is no firewall issue and no certificate issue. May I know why I am getting this issue with below code?

Below is my code:

 

import requests
import json
from requests.auth import HTTPBasicAuth

# Azure DevOps organization and project details
organization = "azdevops"
project = "DevOps"

# Pipeline ID
pipeline_id = "20250224.1"

# Personal Access Token (PAT) - Ensure this is securely managed
pat = "XXX5cfJQRSanltGdfWAma6iPSk83XsdfsdfsadfsdfeAsgbUZz0pPa21JIDk5R6tLATeXXX"

# REST API endpoint for triggering a pipeline
url = f"https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipeline_id}/runs?api-version=7.1-preview.1"

# Headers for authentication
headers = {
    "Authorization": f"Basic {(':' + pat).encode('utf-8').hex()}",
    "Content-Type": "application/json"
}

# Optional request body (e.g., to pass parameters to the pipeline)
data = {
  "resources": {
    "repositories": {
      "self": {
        "refName": "refs/heads/main"
      }
    }
  }
}

try:
    #response = requests.post(url, headers=headers, data=json.dumps(data), auth=HTTPBasicAuth("", pat))
    response = requests.post(url, headers=headers, data=json.dumps(data))
    response.raise_for_status()  # Raise HTTPError for bad responses (4xx or 5xx)
   
    # Process the response
    if response.status_code == 200:
        pipeline_run_details = response.json()
        print("Pipeline triggered successfully!")
        print(f"Pipeline run URL: {pipeline_run_details['_links']['web']['href']}")
    else:
      print(f"Failed to trigger pipeline. Status code: {response.status_code}")
      print(f"Response body: {response.text}")

except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")