Antonio
Antonio

Reputation: 1654

Deploy Firebase Cloud Functions across multiple regions

I'd like to deploy the same cloud function(s) across multiple regions. Is there an easy way to do it?

Upvotes: 9

Views: 1821

Answers (2)

cionzo
cionzo

Reputation: 458

I haven't tried it yet, but the docs say:

You can specify multiple regions by passing multiple comma-separated region strings in functions.region().

Hence, something like

function f(req, res) {
    // your https function implementation here
}

exports.thefunction = functions
    .region('asia-northeast1', 'us-central1')
    .https.onRequest(f);

should work both for deploying the same function across multiple regions and for assigning the same (unique) name to all the "copies".

Upvotes: 1

Doug Stevenson
Doug Stevenson

Reputation: 317402

Since you haven't said what type of function you want to deploy, I'll assume https function. It doesn't make sense to deploy any other type of (background) function to multiple regions, as each may trigger for each event, which would be fairly chaotic. With https functions, you'll have a different URL for each one

You can deploy two different functions with the same implementation to different regions:

function f(req, res) {
    // your https function implementation here
}

exports.f_asia_northeast1 = functions
    .region('asia-northeast1')
    .https.onRequest(f);

exports.f_us_central1 = functions
    .region('us-central1')
    .https.onRequest(f);

Upvotes: 8

Related Questions