I am new to Firebase Realtime database but have been using Firestore for few months till now. I have written a below Cloud Function which tries to increment the access count of a particular record in the Realtime Database using ServerValue feature.But it crashed with Firebase logs
8:01:29.257 am incrCountByRTDB Function execution started
8:01:29.257 am incrCountByRTDB Billing account not configured. External network is not accessible and quotas are severely limited. Configure billing account to remove these restrictions
8:01:29.280 am incrCountByRTDB incrPersonAccessCountBy1
8:01:29.862 am incrCountByRTDB Function execution took 605 ms, finished with status: 'crash'
Code snippet
const admin = require('firebase-admin');
const functions = require('firebase-functions');
admin.initializeApp();
exports.incrCountByRTDB = functions.https.onRequest((req, res) => {
console.log("incrPersonAccessCountBy1");
admin.database().ref('Persons').child('mur_123').child('accessCount')
.set(admin.database.ServerValue.increment(1))
.then(function() {
console.log('Increment succeeded');
return res.status(200).send("Successfully incremented the accesscount");
}).catch(function(error) {
console.log('Increment failed', error);
return res.status(200).send("Increment failed");
})
});
exports.createPersonsCollection = functions.https.onRequest((req, res) => {
admin.database().ref("Persons").child('mur_123').set({
name: 'murali',
accessCount: 0
}).then(function(){
return res.status(200).send("Successfully created the persons collection");
}).catch(function (ex){
console.log("Error", ex);
return res.status(500).send("Creation failed");
})
});
Please let me know if I am missing something and help me resolve this.
Thanks Murali