Bird
Raised Fist0
Firebasecloud~20 mins

Function deployment in Firebase - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Firebase Function Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate
2:00remaining
What happens when you deploy a Firebase function with a syntax error?

You write a Firebase Cloud Function and deploy it using firebase deploy --only functions. The function code contains a syntax error. What will be the result?

Firebase
exports.helloWorld = functions.https.onRequest((req, res) => { res.send('Hello World'); }); // missing closing parenthesis fixed
AThe deployment fails with an error message indicating a syntax error.
BThe function deploys successfully but throws an error only when triggered.
CFirebase automatically fixes the syntax error and deploys the function.
DThe deployment succeeds but the function returns an empty response.
Attempts:
2 left
💡 Hint

Think about what happens if code cannot be parsed correctly before deployment.

❓ Architecture
intermediate
2:00remaining
How to deploy multiple Firebase functions efficiently?

You have three Firebase functions in your project. You want to deploy only two of them without affecting the third. Which command should you use?

Afirebase deploy --only functions:functionOne,functions:functionTwo
Bfirebase deploy --only functionOne,functionTwo
Cfirebase deploy --functions functionOne functionTwo
Dfirebase deploy --only functions
Attempts:
2 left
💡 Hint

Check the syntax for deploying specific functions using the Firebase CLI.

❓ security
advanced
2:00remaining
What is the best practice to secure environment variables in Firebase functions?

You want to store API keys securely for your Firebase functions. Which method ensures the keys are not exposed in your code or public repositories?

AStore keys in <code>.env</code> files and commit them to the repository.
BHardcode the keys directly in the function source code.
CUse Firebase functions config variables with <code>firebase functions:config:set</code> and access them in code.
DStore keys in a public JSON file and fetch them at runtime.
Attempts:
2 left
💡 Hint

Think about how to keep secrets out of source code and public repos.

✅ Best Practice
advanced
2:00remaining
How to minimize cold start latency in Firebase functions?

You notice your Firebase functions have slow response times on the first request after deployment or inactivity. What is a recommended approach to reduce this cold start delay?

ADeploy all functions in a single large file to reduce deployment size.
BKeep functions small and avoid heavy initialization code outside the handler.
CUse synchronous blocking code to ensure all setup completes before responding.
DDisable function scaling to keep instances always warm.
Attempts:
2 left
💡 Hint

Think about what causes cold start delays in serverless functions.

🧠 Conceptual
expert
2:00remaining
What is the effect of setting maxInstances in Firebase function deployment?

You configure a Firebase function with maxInstances: 2. What behavior does this setting enforce?

Firebase
exports.limitedFunction = functions.runWith({ maxInstances: 2 }).https.onRequest((req, res) => { res.send('Hello'); });
AEnsures the function always runs on exactly 2 instances regardless of traffic.
BAllows unlimited instances but restricts each instance to 2 concurrent requests.
CLimits the function to handle only 2 requests total before shutting down.
DLimits the function to run on at most 2 instances simultaneously, controlling concurrency and cost.
Attempts:
2 left
💡 Hint

Consider what maxInstances controls in serverless scaling.

Practice

(1/5)
1. What does the command firebase deploy --only functions do?
easy
A. Uploads and deploys only your Firebase functions to the cloud
B. Deletes all your Firebase functions from the cloud
C. Deploys your entire Firebase project including database and hosting
D. Runs your Firebase functions locally without uploading

Solution

  1. Step 1: Understand the command purpose

    The command firebase deploy --only functions is used to upload and deploy only the cloud functions part of your Firebase project.
  2. Step 2: Compare with other options

    It does not delete functions, deploy the entire project, or run functions locally. It specifically deploys functions to the cloud.
  3. Final Answer:

    Uploads and deploys only your Firebase functions to the cloud -> Option A
  4. Quick Check:

    Deploy only functions = uploads functions [OK]
Hint: Deploy functions only means upload cloud functions [OK]
Common Mistakes:
  • Confusing deploy with delete
  • Thinking it deploys the whole project
  • Assuming it runs functions locally
2. Which of the following is the correct command to deploy only a single function named sendEmail?
easy
A. firebase deploy --only functions
B. firebase deploy --only functions:sendEmail
C. firebase deploy --only sendEmail
D. firebase deploy --functions sendEmail

Solution

  1. Step 1: Recall syntax for deploying a single function

    To deploy a single function, you use firebase deploy --only functions:functionName. Here, functionName is sendEmail.
  2. Step 2: Match the correct option

    firebase deploy --only functions:sendEmail matches this syntax exactly. Other options either deploy all functions or use incorrect flags.
  3. Final Answer:

    firebase deploy --only functions:sendEmail -> Option B
  4. Quick Check:

    Single function deploy uses --only functions:functionName [OK]
Hint: Use --only functions:functionName to deploy one function [OK]
Common Mistakes:
  • Omitting 'functions:' prefix
  • Using wrong flag like --functions
  • Deploying all functions instead of one
3. Given the command firebase deploy --only functions:processOrder, what happens if processOrder function code has a syntax error?
medium
A. The function deploys but crashes when called
B. The deployment succeeds but disables the function automatically
C. Firebase ignores the error and deploys successfully
D. The deployment fails and shows an error message

Solution

  1. Step 1: Understand deployment behavior on syntax errors

    If the function code has a syntax error, Firebase detects it during deployment and stops the process, showing an error.
  2. Step 2: Eliminate incorrect options

    Firebase does not deploy faulty code, so options A, C, and D are incorrect.
  3. Final Answer:

    The deployment fails and shows an error message -> Option D
  4. Quick Check:

    Syntax error blocks deployment = fail and error [OK]
Hint: Syntax errors stop deployment with error message [OK]
Common Mistakes:
  • Assuming deployment succeeds despite errors
  • Thinking Firebase auto-fixes errors
  • Believing function disables automatically
4. You run firebase deploy --only functions but your new function notifyUser does not appear in the cloud. What is the most likely cause?
medium
A. You forgot to export notifyUser in your functions code
B. You deployed with the wrong Firebase project ID
C. You need to restart your local machine before deploying
D. Firebase does not support deploying new functions

Solution

  1. Step 1: Check function export in code

    For Firebase to deploy a function, it must be exported properly in your code. If notifyUser is not exported, it won't deploy.
  2. Step 2: Evaluate other options

    Wrong project ID would cause deployment failure or deploy to wrong place, restarting is unnecessary, and Firebase supports new functions.
  3. Final Answer:

    You forgot to export notifyUser in your functions code -> Option A
  4. Quick Check:

    Functions must be exported to deploy [OK]
Hint: Always export new functions to deploy them [OK]
Common Mistakes:
  • Not exporting the function in code
  • Assuming restart fixes deployment
  • Ignoring project configuration
5. You want to deploy two functions named createUser and deleteUser without deploying others. Which command should you use?
hard
A. firebase deploy --only functions:createUser;deleteUser
B. firebase deploy --only functions:createUser deleteUser
C. firebase deploy --only functions:createUser,deleteUser
D. firebase deploy --only functions:createUser deleteUser --force

Solution

  1. Step 1: Understand syntax for multiple functions deployment

    To deploy multiple specific functions, list them separated by commas after functions: with no spaces.
  2. Step 2: Identify correct option

    firebase deploy --only functions:createUser,deleteUser uses correct comma-separated syntax. Other options use spaces or semicolons which are invalid.
  3. Final Answer:

    firebase deploy --only functions:createUser,deleteUser -> Option C
  4. Quick Check:

    Multiple functions deploy uses comma-separated list [OK]
Hint: Use commas to list multiple functions in --only flag [OK]
Common Mistakes:
  • Using spaces instead of commas
  • Using semicolons to separate functions
  • Adding unnecessary flags like --force
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard