What is the format of Cloud Run service URLs?
Asked Answered
P

3

8

The documentation gives an example of https://gateway-12345-uc.a.run.app as a service URL. Do Cloud Run service URLs always have the -uc.a.run.app suffix, or is this subject to change in the future?

Pierro answered 7/7, 2020 at 23:40 Comment(0)
S
12

The pattern is the following

https://<serviceName>-<projectHash>-<region>.run.app

Where

  • ServiceName is the provided name of your service
  • projectHash is generated by the Platform. You can't know it before the first deployment. SHOULD never change, but sometime (and I don't know the reason, and it's just a caveats from Google) it can change in a different region
  • region: is the region where you deployed. uc.a stand for us-central1. I have service in europe-west1 -> ew.a. I don't know the other region extensions, but deploy over there and you can easily find them.
Spender answered 8/7, 2020 at 7:34 Comment(4)
Is the projectHash always gonna be there even if the serviceName is globally unique?Sparid
The service name is unique in a region AND a project. The project is represented by a hash. Have a try with another project if you want! So YES, the hash is mandatorySpender
@guillaumeblaquiere Is there any way to get the projectHash at runtime?Nicosia
It's possible to get it at runtime. Can you post a new question (and paste the link here), I will be able to share code with you.Spender
S
2

As of August 2022,

From the Official Documentation -

The URL for a Cloud Run service has the format https://[TAG---]SERVICE_IDENTIFIER.run.app, where TAG refers to the traffic tag for the revision that you are requesting, and SERVICE_IDENTIFIER is a stable and unique identifier for a Cloud Run service. Do not parse the SERVICE_IDENTIFIER as it does not have a fixed format, and the logic for SERVICE_IDENTIFIER generation is subject to change.

Sulphate answered 13/8, 2022 at 12:47 Comment(0)
H
0

As of August 2024 Cloud Run can now also use deterministic URLs in addition to the ones containing the project hash as mentioned in previous answers.

As per the official docs the deterministic URL will be of the form https://[TAG---]SERVICE_NAME-PROJECT_NUMBER.REGION.run.app

Where

  • TAG is the optional traffic tag for the revision that you are requesting.
  • PROJECT_NUMBER is the Google Cloud project number.
  • SERVICE_NAME is the name of the Cloud Run service.
  • REGION is the name of the region, such as us-central1.

Note there are some caveats in that the [TAG---]SERVICE_NAME-PROJECT_NUMBER label must be no more than 63 characters. If you are not using a TAG then this should always be the case even with a maximum length SERVICE_NAME

Habitual answered 4/9 at 4:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.