title: Cloud functions crash with `Error: Can't determine Firebase Database URL.`
body: <p>We have some Cloud functions to send notifications to users. (and others that calculates other stuff). All these CF are using the Realtime database , that is where we are hosting all the data.</p>
  
  <p>But few days ago, we added new functions that sincronize Realtime database to a new table in Firestore (due to migration of db process)</p>
  
  <p>And I think here is the problem. We detect that some pushes are not being sended to users,some data is not being writed in the proper tables... and taking a look to the Log of the functions we get this:</p>
  
  <pre><code>Error: Can't determine Firebase Database URL.
      at FirebaseDatabaseError.FirebaseError [as constructor] (/srv/node_modules/firebase-admin/lib/utils/error.js:42:28)
      at new FirebaseDatabaseError (/srv/node_modules/firebase-admin/lib/utils/error.js:202:23)
      at DatabaseService.ensureUrl (/srv/node_modules/firebase-admin/lib/database/database.js:88:15)
      at DatabaseService.getDatabase (/srv/node_modules/firebase-admin/lib/database/database.js:55:26)
      at FirebaseApp.database (/srv/node_modules/firebase-admin/lib/firebase-app.js:231:24)
      at FirebaseNamespace.fn (/srv/node_modules/firebase-admin/lib/firebase-namespace.js:280:45)
      at exports.sendCommunityMessageNotification.functions.database.ref.onWrite (/srv/index.js:348:49)
      at cloudFunction (/srv/node_modules/firebase-functions/lib/cloud-functions.js:131:23)
      at /worker/worker.js:825:24
      at &lt;anonymous&gt;
  </code></pre>
  
  <p>But I don't know, what I have to do, or modify , because I didn't found any solution</p>
  
  <p>Here is a little example of the new function, and an older one that stopped working.</p>
  
  <pre><code>const admin = require('firebase-admin');
  admin.initializeApp();
  
  const functions = require('firebase-functions');
  const firestore = admin.firestore();
  
  //NEW FUNCTION
  exports.createUpToOnFirestore = functions.database.ref('/upto/{uptoId}').onCreate((snap,context) =&gt; {
  .....
    return firestore.collection('uptos')
                    .doc(uptoId)
                    .set(json)
  }
  
  //OLD FUNCTION
      exports.sendInvitationCreated = functions.database.ref('/invitation/{invitationId}')
      .onCreate((snap,context) =&gt; {
      .....
      ...
      for (var i = 0; i &lt; Object.keys(userList).length; i++) {
            const user = users[i];
            const userValue = usersValues[i];
  
            if (userValue === 3){ //Value 3 means user is Admin
              adminUserId = user;
            }
            console.log('Getting promise of user uid=',user);
            console.log('adminUserId=',adminUserId);
      //HERE IS WHERE THE FUNCTIONS CRASH
            AllFollowersFCMPromises[numberNotifications] = admin.database().ref(`/user/${user}/`).once('value');
            numberNotifications = numberNotifications+ 1;
        }
      ...
      ...
      }
  </code></pre>