error creating storage bucket using gsutil - firebase

I do not have billing associated with my google account but when I create a new firebase project I can create a default bucket just by going to storage section on console and pressing get start (check the screenshot)
but when I try to create this default gsutil
gsutil mb -p project-id gs://project-id.appspot.com/
I got this error
AccessDeniedException: 403 The project to be billed is associated with an absent billing account.
is there any way to enable this default storage using gsuitl, code or command without opening the console site?

Firebase's default bucket works basically by building the storage costs into your Firebase bill. But gsutil is a GCS tool, i.e., you're attempting to use the underlying storage that Firebase uses. To do that, you need to set up billing first.

Looks like it is billing issue, first setup billing then try to create bucket.
you can use gsutil or use GCP UI to create bucket

Related

Specify non-default bucket to enable Firebase Storage

I have a situation where I'm trying to enable Firebase Storage but also have an App Engine deployment which already created the buckets {project_name}.appspot.com and it give me the following error message:
I'm aware you can change the Firebase bucket after enabling Firebase Storage from the Firebase console, however I don't see a way to do it before/while enabling Firebase Storage.
I'm working with a few restrictions and want to see if I can enable Firebase storage with those. My first restriction is that I cannot create a separate GCP project for this. We have billing credits which are linked to the project. Another is that I cannot change the App Engine configuration, or rather doing so will only be done in the worst case since that's already being used for a production workload. Lastly, our parent organization is pretty strict in terms of their Org policies and is likely not willing to change it.
Is there a way specify a different bucket to enable Firebase Storage to avoid the conflict?
I created a GCP project with an App Engine app and a Firebase project with Firebase Storage enabled. According to the documentation these services require a default resource location in order to be initially provisioned. Firebase Storage makes use of the same default bucket as App Engine to initialize. It appears that your organization might have blocked access to this bucket, which makes Firebase Storage not to work initially. You should request the organizational policies to be temporarily allowed while Firebase Storage is provisioned, and then, as you mentioned, you can change the bucket used by Firebase Storage to a different one. Firebase makes use also of the following Storage service account:
You should make sure that this account has permissions to perform its operation at creation time of the bucket, from the FAQ it also explains this is needed:
Cloud Storage for Firebase creates a default bucket in the App Engine free tier.

Download data from Firebase Storage via browser

I can see this list of directories in the browser. Here I can create new dirs or delete it.
But how can I download it?
Can I move all incoming data to our paid Google Cloud Platform Bucket?
And this is about paid bucket. We have this view:
When you use Storage in Firebase, you're actually just using a Google Cloud Storage bucket. The easiest way to work with the contents of a Cloud Storage bucket is with the gsutil comment line. When you have that installed and configured, then you can run commands to copy the contents of the bucket to and from your local machine, with gsutil cp, for example:
gsutil cp -r gs://deeplabandroid.appspot.com/Values .

Difference between Firebase service account key files from Firebase and from GCloud?

I am running scripts to interact with Firestore (e.g. creating a doc). I've provided a service account key file to do so (tried with key files from Firebase and GCloud) - scripts run the same.
I am aware that Firebase is now built / closely linked to GCloud so I am expecting the key files to be similar.
However, the docs recommend initializing the sdk with a key from Firebase console when adding Firebase admin to your server and from GCloud Console for unit testing.
So here are my questions:
Why recommend 2 different ways to generate them? Is one more appropriate than the other?
Do service account key files generated in Firebase (1) and GCloud (2) consoles differ in terms of scope? Do they allow the same operations? Are they granted equivalent permissions?
Firebase Console > Project Settings > Service Accounts > Firebase Admin SDK > Create new private key
https://console.firebase.google.com/project/[my-project-id]/settings/serviceaccounts/adminsdk
Google Cloud Console > IAM & Admin > Service Accounts > App Engine default service account > Create key
https://console.cloud.google.com/iam-admin/serviceaccounts?project=[my-project-id]
The service account and credentials provided by the Firebase console are no different than one that you'd create in the Cloud console. Firebase is just making it easier to get started, so you don't have to learn the Cloud console. If you want to use the one provided by Firebase, fine. If you want to use one you create and configure in the Cloud console, fine. The Firebase service account should be visible in the Cloud console just like any other. When it comes to assigning permissions to individual products, you can still choose either one to work with. It's up to you.

Failed to export Firestore database

I am trying out the new export feature of the FireStore as shown on this link, and I keep getting error message:
gcloud alpha firestore export gs://backup --async
ERROR: (gcloud.alpha.firestore.export) PERMISSION_DENIED: Service account does not have access to Google Cloud Storage file: /backup. See https://cloud.google.com/datastore/docs/export-import-entities#permissions for a list of permissions needed. Error details: projectABC#appspot.gserviceaccount.com does not have storage.buckets.get access to backup.
I've run the command to add my service account as a storage.admin, and that command succeed:
gcloud projects add-iam-policy-binding projectABC --member='serviceAccount: projectABC#appspot.gserviceaccount.com' --role='roles/storage.admin'
Could someone help?
You can't select an arbitrary bucket name for your backup. You're using "gs://backup". Instead, you need to use the url for an actual bucket that you've created an you fully control.
Give storage admin access to IAM role

how to find my Google application credentials key.json

I try to run Firebase Functions locally by following the instruction here.
It mentioned these steps:
$ export GOOGLE_APPLICATION_CREDENTIALS="path/to/key.json"
$ firebase experimental:functions:shell
OR
$ firebase serve --only functions
How can I find my path/to/key.json?
Presumably you followed the instructions on the page you linked to:
To set up admin credentials for emulated functions (other than Cloud
Firestore and Realtime Database):
Open the Service Accounts pane of the Google Cloud Console.
Make sure that App Engine default service account is selected, and use the options menu at right to select Create key.
When prompted, select JSON for the key type, and click Create.
Set your Google default credentials to point to the downloaded key
Only you know the path of the JSON file you just downloaded from the console. Put the full path to that file there.

Resources