GoogleCloudPlatform / functions-framework-java

FaaS (Function as a service) framework for writing portable Java functions
Apache License 2.0
133 stars 63 forks source link

Function deploy problem #214

Closed Polkasa closed 1 year ago

Polkasa commented 1 year ago
      <plugin>
        <groupId>com.google.cloud.functions</groupId>
        <artifactId>function-maven-plugin</artifactId>
        <version>0.10.1</version>
        <configuration>
          <functionTarget>pl.test.adapter.function.TestFunction</functionTarget>
          <projectId>test-project</projectId>
          <name>test-function</name>
          <serviceAccount>deploytestfunction@test.gserviceaccount.com</serviceAccount>
          <serviceAccountKeyFile>key.json</serviceAccountKeyFile>
        </configuration>
      </plugin>

But when i run pipeline with mvn function:deploy -f pom.xml i got this error:

Executing Cloud SDK command: gcloud functions deploy test-function --trigger-http --entry-point=pl.test.adapter.function.TestFunction --service-account=deploytestfunction@test.gserviceaccount.com --runtime=java11 --project=test-project
Jul 04, 2023 6:27:54 AM com.google.cloud.tools.appengine.operations.Gcloud runCommand
SEVERE: ERROR: (gcloud.functions.deploy) You do not currently have an active account selected.
Please run:
  $ gcloud auth login
to obtain new credentials.
If you have already logged in with a different account, run:
  $ gcloud config set account ACCOUNT
to select an already authenticated account to use.
Jul 04, 2023 6:27:54 AM com.google.cloud.functions.plugin.DeployFunction execute
SEVERE: null

What is the problem, am i missing something? I can mention that before "Executing Cloud SDK command: gcloud functions deploy" i didnt get any command about authentitaction this is the first what is executing

garethgeorge commented 1 year ago

Hi @Polkasa sorry this probably isn't documented as well as it could be! At its simplest, the functions-framework maven plugin is a wrapper around the gcloud CLI (i.e. see the maven plugin implementation which is really just crafting gcloud commands). Because the plugin is delegating the actual work of deploying your function to gcloud, the maven plugin will only work on a system that already has gcloud installed and authenticated with some account that has access to the projects you want to deploy to.

garethgeorge commented 1 year ago

Hi @Polkasa , I'm hoping that helped answer your question. I'm going to go ahead and close this for now but please feel free to reopen if you're still running into an issue.