is there a way to specify the Region/Zone where my firebase functions will be deployed.
Actually i didn\'t found anything about that in the documentation and my fun
From docs: https://firebase.google.com/docs/functions/locations
Now available in the following regions:
// before
const functions = require('firebase-functions');
exports.webhook = functions
.https.onRequest((req, res) => {
res.send("Hello");
});
// after
const functions = require('firebase-functions');
exports.webhookEurope = functions
.region('europe-west1')
.https.onRequest((req, res) => {
res.send("Hello");
});
"rewrites": [
{
"source": "**",
"run": {
"serviceId": "<service id>",
"region": "europe-west1"
}
}
]
},
firebaser here
Update (2018-07-25):
It is now possible to specify the region for your Cloud Functions in Firebase you specify that region in your code and deploy the change. E.g.:
exports.myStorageFunction = functions
.region('europe-west1')
.storage
.object()
.onFinalize((object) => {
// ...
});
For full details see the Firebase documentation on Cloud Functions locations (from where I got the above snippet) and modifying the region of a deployed function.
To use the same custom region for all your functions, you do something like this.
import * as functions from 'firebase-functions';
const regionalFunctions = functions.region('europe-west1');
export const helloWorld = regionalFunctions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});
export const helloWorld2 = regionalFunctions.https.onRequest((request, response) => {
response.send("Hello from Firebase 2!");
});
To have Firebase functions deployed to a region also work in local emulation, one must initialise the client as such:
const functions = LOCAL ? firebase.app().functions(/*functionsRegion*/) :
firebase.app().functions(functionsRegion);
const fun = functions.httpsCallable('your_function_name');
i.e. the code is not the same. Adding a region in the emulated case makes the calls get lost, without an error.
LOCAL
is a client side value I've made to know, whether the back end is running in the cloud, or set up for local emulation.
Surely, this is a corner case that Firebase will iron away?
firebase-tools 8.6.0, firebase
7.16.1