Azure python runbook import_py3package_from_pypi : Exception: Error importing package cryptography into Automation account. Error code is 400. from p

Grant Fullston 25 Reputation points
2024-05-08T03:56:09.8433333+00:00

hi all, on Azure Automations

I am receiving this Exception when I try to run import_py3package_from_pypi runbook on module msgraph-sdk -v 1.2.0.

I only require the functionality from the runbook to access the microsoft graph using certificate credentials (I believe this is the best way please correct me if not) to access sharepoint files. I have been stuck on this for ages, any help would be great.

My output log says earlier that i have

Collecting cryptography>=2.5 (from azure-identity>=1.12.0->msgraph-sdk==1.2.0)
  Downloading cryptography-42.0.7-cp39-abi3-manylinux_2_28_x86_64.whl.metadata (5.3 kB)

then later

Downloading cryptography-42.0.7-cp39-abi3-manylinux_2_28_x86_64.whl (3.8 MB)

finally:

Extracted version   2.8 min_req_versionor 42.0.7
Extracted version   2.9 min_req_versionor 42.0.7
Extracted version   2.9.1 min_req_versionor 42.0.7
Extracted version   2.9.2 min_req_versionor 42.0.7
Extracted version   3.0 min_req_versionor 42.0.7
Extracted version   3.1 min_req_versionor 42.0.7
Extracted version   3.1.1 min_req_versionor 42.0.7
Extracted version   3.2 min_req_versionor 42.0.7
Extracted version   3.2.1 min_req_versionor 42.0.7
Could not find WHL from PIPI for package cryptography and version 42.0.7
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,145 questions
{count} vote

1 answer

Sort by: Most helpful
  1. AnuragSingh-MSFT 20,831 Reputation points
    2024-05-15T07:59:50.6833333+00:00

    @Grant Fullston, Thank you for posting this question on Microsoft Q&A.
    Based on the error message, they are coming from the resolve_download_url() method here - https://github.com/azureautomation/runbooks/blob/164cf84ac66b444ea443a9f8c736c5042c64eeb3/Utility/Python/import_py3package_from_pypi.py#L63

    For cryptography-42.0.7-cp39-abi3-manylinux_2_28_x86_64.whl it seems to be failing because of the following test condition:

    for url in urls:
            if 'abi3-win_amd64.whl' in url and 'cp36' in url and version in url:
                print ("Detected download uri %s for %s" % (url, packagename))
                return(url) 
    

    Note that list of .whl files at cryptography 42.0.7 does not match any of the other criteria. There is a partial match here but fails for condition 'cp36' in url . The match should have been 'cp39' in url or for cp37 (no cp36 available).

    I have not tested it yet (as I am running into some issues with respect to my automation account), but I believe that adding a new test scenario in the resolve_download_url function like below should help resolve this particular error:

        for url in urls:
            if 'abi3-win_amd64.whl' in url and 'cp39' in url and version in url:
                print ("Detected download uri %s for %s" % (url, packagename))
                return(url) 
    
    

    Hope this helps.

    Please let me know if you have any questions.

    0 comments No comments