> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/code/integrations/providers/google-cloud-functions.md).

# Google Cloud Functions

Connect Google Cloud Functions to the Code module.

Google Cloud Functions (now part of Cloud Run functions) runs your functions in your own Google Cloud project. Norbix connects with the JSON key of a service account.

{% hint style="warning" %}
You can connect Google Cloud Functions in Cloud, but Norbix cannot call your functions yet: every test answers *Provider 'GoogleCloudFunctions' is not wired up yet* (the server has no Google Cloud Functions client). Connect it now so the settings are ready; nothing is sent to Google. Through the SDK, CLI and API the integration is saved the same way.
{% endhint %}

## Get your credentials

1. Sign in to the [Google Cloud console](https://console.cloud.google.com/) and pick the project your functions run in. Note its **Project ID**, for example `bookshop-prod`.
2. Open **IAM & Admin → Service accounts → Create service account**, name it, for example `norbix-invoker`, and give it a role that may call your functions, for example **Cloud Run Invoker** (or **Cloud Functions Invoker** for 1st gen functions). Google guides: [Create service accounts](https://cloud.google.com/iam/docs/service-accounts-create) · [Authenticate for invocation](https://cloud.google.com/functions/docs/securing/authenticating).
3. Open the service account → **Keys → Add key → Create new key → JSON**. The JSON file downloads once; keep it safe. Google guide: [Create and delete service account keys](https://cloud.google.com/iam/docs/keys-create-delete).
4. Note the region of your functions, for example `europe-west1` (list: [Locations](https://cloud.google.com/functions/docs/locations)).

The old settings for labels and automatic refresh are gone — the V2 form has only the four fields below.

## Connect it in Cloud

**Where:** Code → Integrations → **Add New Integration** → Google Cloud Functions → **Connect** · `/projects/<project>/code/integrations/new/google-cloud-functions`

| Field                    | Required | What it does                                                                 | Example                                                           |
| ------------------------ | -------- | ---------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| Project ID               | yes      | The Google Cloud project of your functions.                                  | `bookshop-prod`                                                   |
| Region (optional)        | no       | Where your functions run. Empty = the platform default.                      | `europe-west1`                                                    |
| Service Account JSON Key | yes      | The whole content of the JSON key file. Stored encrypted, never shown again. | `{ "type": "service_account", "project_id": "bookshop-prod", … }` |
| Integration Name         | yes      | How the integration is listed in Norbix.                                     | `Bookshop Google`                                                 |

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-e8b437e95208e5a107d89916e2d4c6e88f35b022%2Fgoogle-cloud-functions-form-1.png?alt=media" alt="New Google Cloud Functions Integration filled with bookshop-prod, europe-west1, a placeholder service account key and the name Bookshop Google"><figcaption><p>The filled form (the key is a made-up placeholder).</p></figcaption></figure>

Press **Save**. The title becomes *Editing Google Cloud Functions integration*, the badges say **ENABLED** and **NOT TESTED**, the id (`int_…`) appears with a copy button, and the key field is empty again.

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-9ac7e97cbafc81647d876de9cf69f205ec54761e%2Fgoogle-cloud-functions-saved-2.png?alt=media" alt="Editing Google Cloud Functions integration with the badges ENABLED and NOT TESTED, the id int_4GOaLNylLsaQQYBKwZFs0J, bookshop-prod and europe-west1"><figcaption><p>After save.</p></figcaption></figure>

## Test and set as default

**Test integration** answers *Provider 'GoogleCloudFunctions' is not wired up yet* and sets **TEST FAILED** — see [Test an integration](/codemash/cloud/code/integrations/test.md). **Set as default** is accepted but not kept — see [Set as default](/codemash/cloud/code/integrations/set-default.md). To turn it off: [Disable or delete](/codemash/cloud/code/integrations/disable.md).

From code (inside `integration`, `projectId` is the Google Cloud project, not the Norbix project):

```ts
await norbix.hub.code.saveCodeIntegration({
  integration: {
    provider: 'GoogleCloudFunctions',
    integrationName: 'Billing Google',
    isEnabled: true,
    projectId: 'billing-prod',
    region: 'europe-west1',
    serviceAccountJsonKey: '{ "type": "service_account", "project_id": "billing-prod", "private_key": "placeholder-not-real" }',
  },
});
```

```sh
norbix hub code integration save --integration:json '{"provider":"GoogleCloudFunctions","integrationName":"Reports Google","isEnabled":true,"projectId":"reports-prod","region":"europe-west1","serviceAccountJsonKey":"placeholder-service-account-key-not-real"}'
```

API: [Save Code Integration](/codemash/api-reference/code/integrations/save-code-integration.md)

## Common errors

| Message                                                                        | Cause                                               | Fix                                                                       |
| ------------------------------------------------------------------------------ | --------------------------------------------------- | ------------------------------------------------------------------------- |
| *Required* under **Project ID**                                                | The Google Cloud project id is empty.               | Type the project id.                                                      |
| *Required* under **Service Account JSON Key**                                  | The key is empty — it is asked again on every save. | Paste the content of the key file again.                                  |
| *Provider 'GoogleCloudFunctions' is not wired up yet.* on **Test integration** | Norbix has no Google Cloud Functions client yet.    | Nothing to fix on your side; the test will work when the client is added. |
