Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 204
Antonio Avatar asked Sep 09 '18 11:09

Antonio


1 Answers

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);
like image 56
Doug Stevenson Avatar answered Sep 25 '22 19:09

Doug Stevenson