title: Firebase Function fails connecting to Firestore using Admin SDK
body: <p>I'm writing a Firebase Function using the Admin SDK that should retrieve data from Firestore (function triggered upon RealTime DB insert event).</p>
  <p>It looks as if the Relatime DB is kicking in fine, but when I added the Firestore code, it is failing on the Firestore connection with the following error on deployment:</p>
  <pre><code>    Error: Missing expected firebase config value databaseURL, config is actually{&quot;firebase&quot;:{&quot;projectId&quot;:&quot;simplify-poc&quot;,&quot;databaseURL&quot;:&quot;https://simplify-poc-default-rtdb.firebaseio.com&quot;,&quot;storageBucket&quot;:&quot;simplify-poc.appspot.com&quot;,&quot;locationId&quot;:&quot;us-central&quot;}}
       If you are unit testing, please set process.env.FIREBASE_CONFIG
  </code></pre>
  <p>This is my function code, what am I missing?</p>
  <pre class="lang-js prettyprint-override"><code>const functions = require(&quot;firebase-functions&quot;);
  
  const admin = require(&quot;firebase-admin&quot;);
  admin.initializeApp();
  
  const db = admin.firestore();
  
  async function getHelperToken(helperId) {
    //Get token from Firestore
    const tokensRef = db.collection(&quot;tokens&quot;);
    const helper_token = await tokensRef
      .where(&quot;user&quot;, &quot;==&quot;, helperId)
      .get(&quot;device_token&quot;);
    return helper_token;
  }
  
  //DB triggered function - upon writing a child in the HelpersInvitations reference
  exports.sendHelperInvitation = functions.database
    .ref(&quot;/HelpersInvitations/{helper_invitation_id}&quot;)
    .onCreate((snapshot, context) =&gt; {
      const studentId = snapshot.val().studentId;
      const studentName = snapshot.val().studentName;
      const helperId = snapshot.val().helperId;
      const title = snapshot.val().title;
      const body = snapshot.val().body;
  
      //Get the helper token by Id
      const helper_token = getHelperToken(helperId);
      //Notification payload
      const payload = {
        notification: {
          title: title,
          body: body,
          icon: &quot;default&quot;,
          click_action: &quot;com.skillblaster.app.helperinvitationnotification&quot;,
        },
      };
  
    //    //Send the notification
    return admin.messaging().sendToDevice(helper_token, payload);
  });
  </code></pre>