Cloud function 2gen unable to install package from artifact registry

Hello,

I am attempting to deploy a Cloud Function gen2 that requires a specific Python package from my private  Google Cloud's Artifact Registry hosted on another GCP project. I have set up my requirements.txt file to specify this dependency and have followed Google's official documentation on specifying dependencies for Python Cloud Functions: Specifying dependencies (Python).

Setup and Configuration:

  1. I granted the Cloud Build Service Account the Artifact Registry Reader permission for the project that hosts the Artifact Registry.

  2. My requirements.txt is structured as follows:

 

 
my-package

    3.  I am deploying a minimal Cloud Function with the above requirements.txt.

Error Encountered:

During deployment, the operation fails with the subsequent output:

 

 
[builder] Failure: (ID: c84b3231) Looking in indexes: https://pypi.org/simple, https://my-region-pypi.pkg.dev/my-project-with-registry/my-python-repo/simple/
[builder] ERROR: Could not find a version that satisfies the requirement my-package==XX.XX.XX (from versions: none)

Additional Information:

  • The documentation clearly states, "You only need to include the Artifact Registry URL in your requirements.txt without generating additional credentials." However, this approach doesn't seem to work in my case.

  • I also tried creating an Artifact Registry within the same project as the Cloud Function, but the issue persists.

Request for Assistance:

I am unsure about what's causing this issue. Is there something I might have overlooked or an additional step that isn't covered in the documentation? Any insights or recommendations would be greatly appreciated.

Thank you for your assistance!

 

0 4 1,201
4 REPLIES 4

Hi @samuel-bak,

Welcome to Google Cloud Community!

The Cloud Function builder could not find the specified package in any of the indexes it searched, including the Artifact Registry repository specified in the requirements.txt file. This could be due to a number of reasons, such as the package not existing in the repository, the package not being publicly accessible, the Cloud Function builder not having permission to access the repository, or the Artifact Registry repository URL being incorrect.

To troubleshoot the issue, you can try the following:

  • Make sure that the package exists in the Artifact Registry repository.
  • Make sure that the package is publicly accessible.
  • Grant the Cloud Function builder permission to access the repository.
  • Verify that the Artifact Registry repository URL is correct.
  • Try deploying the Cloud Function to a different region.

If you are still having trouble, you can contact Google Cloud support for assistance.

Hello Christian,

Thank you for your response.

  • The package is available in the Artifact Registry.
  • I can pull the package locally using gcloud and the cloud function's service account key.
  • The Cloud Build Service Account has access permissions to the repository.
  • The repository URL in Artifact Registry is accurate.

I've identified a workaround not mentioned in the docs: I adjusted the --extra-index-url based on the output from:

gcloud artifacts print-settings python --repository=my-repo

This suggests an issue with read permissions to the Artifact Registry, as using the service account key in the extra-index-url resolved it. However, this approach isn't viable for production, as it exposes the service account secret in the requirements.txt.

Could you provide further insight? @christianpaula

 



Do you have any insights on the issue ? @christianpaula 

@christianpaula wrote:

Hi @samuel-bak,

Welcome to Google Cloud Community!

The Cloud Function builder could not find the specified package in any of the indexes it searched, including the Artifact Registry repository specified in the requirements.txt file. This could be due to a number of reasons, such as the package not existing in the repository, the package not being publicly accessible, the Cloud Function builder not having permission to access the repository, or the Artifact Registry repository URL being incorrect.

To troubleshoot the issue, you can try the following:

  • Make sure that the package exists in the Artifact Registry repository.
  • Make sure that the package is publicly accessible.
  • Grant the Cloud Function builder permission to access the repository.
  • Verify that the Artifact Registry repository URL is correct.
  • Try deploying the Cloud Function to a different region.

If you are still having trouble, you can contact Google Cloud support for assistance.


 

I'm having this same issue - @samuel-bak did you manage to resolve it?

I am also having the same issue, with the same issues as OP and am able to produce the same effects.