"No project ID could be determined from the Cloud SDK configuration" when running psqworker - google-app-engine-python

When I was going through the Google Cloud tutorial: https://cloud.google.com/python/getting-started/using-pub-sub#running_the_app_on_your_local_machine
I got the following error:
google.auth._default No project ID could be determined from the Cloud SDK configuration. Consider running gcloud config set project or setting the GOOGLE_CLOUD_PROJECT environment variable
I did 'gcloud config set project [my project name]' with no success.
What's the problem?
Update: I've deployed app engines previously without any problem. The problem only happens when I run the psqworker for this Pub/Sub function. I know my project ID and used it before.

The first thing I would try would be:
gcloud info
This will tell you the account and project that gcloud is currently set to.
You may also find the available projects for your account with the following gcloud command:
gcloud projects list

Locate the project ID and project number
There are two ways to identify your project: the project number and project ID.
The project number is automatically assigned when you create a project.
The project ID is a unique identifier for a project. When you first create a project, you can accept the default generated project ID or create your own. A project ID cannot be changed after the project is created, so if you are creating a new project, be sure to choose an ID that you'll be comfortable using for the lifetime of the project.
Note: You should be aware that some resource identifiers (such as project IDs) might be retained beyond the life of your project. For
this reason, avoid storing sensitive information in resource
identifiers.
To locate your project ID and project number:
Go to the Cloud Platform Console
From the projects list, select the name of your project.
On the left, click Dashboard. The project name and ID are displayed in the Dashboard.

TL;DR
Use virtualenv -p C:/Python27/python.exe name-of-env instead of virtualenv -p C:/Python36/python.exe name-of-env in the tutorial
I ran into a similar issue. Here are the steps I went through and why. Hope it helps!
First I tried to specify the id with the command gcloud config set project name-of-your-project
This resulted in the error
ERROR: Python 3 and later is not compatible with by the Google Cloud SDK. Please use a Python 2.7.x version.
If you have a compatible Python interpreter installed, you can use it by setting
the CLOUDSDK_PYTHON environment variable to point to it.
I thought this error was weird because the tutorial tells you to use python3 but it doesn't work. So I created a virtualenv with python2.7 like so
virtualenv -p C:/Python27/python.exe name-of-env (I have python 2 and 3 so its easier to specify the whole path to the .exe file)
Then follow the rest of the tutorial with
name-of-env\scripts\activate
pip install -r requirements.txt
Don't know why you have to use python3 when it doesn't even work.

Related

"SFDX: Deploy Source to Org" function missing

Hello I have created a LWC project in VS Code but the "SFDX: Deploy Source to Org" option is missing when I Right-click the default folder under force-app/main.
I have authorized the org and set a default scratch org.
Please help.
For scratch orgs it's more "natural" to push and pull the changes, let SFDX figure out what changed on your system / what changed server-side (new field, new report? new object? good luck spelling it all out in package.xml, life is too short for it). The team behind VSCode sfdx plugin made conscious decision to hide these options.
Try with sfdx force:source:push.
If you need single file there's still source-ish deploy command (will warn you if you're overwriting something changed on server / by another dev and you can force deploy if you want).
https://developer.salesforce.com/tools/vscode/en/user-guide/development-models
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_develop_any_org.htm
The deploy-retrieve are old school metadata api commands

"Unauthorized" while selecting forms for associating workflow

I am using the latest opensource formsflow.ai v4.0.2. I brought the entire project to my personal laptop. I followed the Docker full installation guide. Docker is running fine. In http://localhost:3000, login as formsflow-designer and selected an existing form for associating workflow, If I select one of the forms it shows :unauthorized" as shown in the below screenshot.
This "unauthorised" error is due to wrongly configured environment variable for forms-flow designer role (DESIGNER_ROLE_ID). Please refer https://github.com/AOT-Technologies/forms-flow-ai/blob/master/forms-flow-forms/README.md#formsflow-forms-userrole-api for obtaining the required env for roles and use those in the environment variables mentioned in the table https://github.com/AOT-Technologies/forms-flow-ai/tree/master/deployment/docker#formsflowai-keycloak-variable-settings . And rebuild and deploy forms-flow-web. This should fix your issue.

Is it possible to auto select different "gcloud" configs for different projects in multiple workspaces / folders ? Gcloud on multiple projects

From this question and this article we get that is possible to create multiple configs for the gcloud SDK.
But it seems that you have to manually switch between then, by running:
gcloud config configurations activate <CONFIG_NAME>
But is there a way for each config to be automatically selected whenever I open up a project workspace/folder on VSCode? How can I do this?
I've just tested activating a new config on a different VSCode project. That seems to update it globally. Now, all of my VSCode windows (different projects) are seeing the same activated config.
Isn't it dangerous? I mean, I could be uploading stuff to the cloud on a different project that I'm not aware of. How do people usually handle this? Do I need to run the activate command on every script before deploying something?
Unfortunately, I am not aware of such a possibility, however I have found something interesting that may help you. There is following extension:
GCP Project Switcher
The extension only allows you to change projects, however as I looked into the code it is running gcloud set config project command under the hood. You could raise a request to add the possibility to change the whole configuration to the instead of project only, as it is a very similar approach.

Google Cloud Platform - Specifying Project Name

I am trying to follow Google's instructions on deploying a Cloud Function from the command line. I cloned their sample project, but when I used gcloud functions deploy to deploy it, it complained that it failed to find attribute [project]. I had to provide that manually.
Where in their docs to they talk about setting the project attribute? I must've missed it, and it seems pretty important ...
This answer is in addition to #Kolban.
You can modify your gcloud settings at any time. Here are some common ones:
gcloud config set core/project my-project-id
gcloud config set compute/region us-central1
To list your projects:
gcloud projects list
To see your current settings:
gcloud config list
To see your authorization settings:
gcloud auth list
Then there are settings for individual services such as Cloud Run:
gcloud config set run/region us-central1
To get help to see the vast number of settings available:
gcloud config --help
All of this is documented. Just put a command into Google and a document link will appear. For example put this string into Google: "gcloud compute instances create". The first link takes you to the command documentation.
When you install the Google Cloud SDK (which provides the gcloud command), you have the opportunity to create one or more configurations (including the default). Think of these as "profiles" for your interaction with GCP. A configuration includes:
Your identity
Your default project
Your default region/zone
See the following article:
Initializing Cloud SDK
It sounds like you either didn't run gcloud init or didn't identify a project you wanted to use when you did run it. When you subsequently run gcloud commands and don't specify a project, then the current configuration project will be used. If you didn't set one, then that would explain the error encountered.

Application Packages with VM configuration

I'm trying to use application packages in the way they're described in this
https://learn.microsoft.com/en-us/azure/batch/batch-application-packages
But I keep getting an error saying
application path not found.
Any ideas what could be wrong? Or
How do application packages work in the background, that might help me debug the error?
EDIT: I am trying to add an application package specific to my job manager task. I added the package as a zip file through Azure portal under the name JobManagerTask and version 1.0. Here is the code I'm using to reference it:
string taskID = "tasktest1";
// Obtain application package that has executables for job manager task
ApplicationPackageReference jobManagerApp = new ApplicationPackageReference { ApplicationId = "JobManagerTask", Version = "1.0" };
// Command Line
string commandLine = #"cmd /c %AZ_BATCH_APP_PACKAGE_JOBMANAGERTASK#1.0%\\JobManagerTask.exe";
// Create a CloudTask
CloudTask oneTask = new CloudTask(taskID, commandLine);
oneTask.ApplicationPackageReferences = new List<ApplicationPackageReference> { jobManagerApp };
// Provide elevated admin access to the task
oneTask.UserIdentity = new UserIdentity(new AutoUserSpecification(elevationLevel: ElevationLevel.Admin, scope: AutoUserScope.Task));
// Could add task resource files if needed here
await batchClient.JobOperations.AddTaskAsync(jobID, oneTask);
Coool, so i created a small barebone app. :) rest details are below and please feel free to ping me if I can helpout further.
so I tried with almost identical code like your's minus couple of flags like userIdentity and seems like I had my sample working fine, I think the error will only happen in case where the application package is not correctly refer'd. like if my *.exe reside in some diff dir structure etc. :)
I thought it will be a good idea to create a vanilla (i.e. from scratch application for you by taking one of the existing samples.) which might give you a chance to quickly take a look and see if you missed anything.
Please feel free to ping me and I will help you out to achieve your coal, I think its something very small like path is wrong etc. (which error message also suggest)
The Application reside here:
https://github.com/Tatsinnit/quick_sample_batchapppkgworking
Detail:
Detail is also there in the Readme for the git but as its a good practice in SO to detail everything here I will copy paste what I have written in readme here for you.
quick_sample_batchapppkgworking
Readme: barebone quick app:
Please note thta this app is nothing but a quick sample made based on the existing sample for DotNetTutorial.
Following code is generated just as a sample code for end to end app package working feature.
• https://learn.microsoft.com/en-us/azure/batch/
• https://learn.microsoft.com/en-us/azure/batch/batch-technical-overview
App Pacakges:
• https://learn.microsoft.com/en-us/azure/batch/batch-application-packages
• https://azure.microsoft.com/en-us/blog/application-packages-and-task-dependencies-now-available-on-azure-batch/
The overview as how it works is fairly simple, when user uploads to adds an application package the package becomes available within node’s working directory (wd). The env var gets created to handle multiple updated versions of the app: (the timestamp is automatically part of the App pkg populated env var you dont need to do anything to handle this.)
set AZ_BATCH_APP_PACKAGE_TEST1#1.0=C:\user\tasks\applications\wd\test1\1.0\2017-07-14T21.45.45.765Z
Hence if user has correct package version all set and node has app pkg they can invoke that from whatever the need is for application package: (something like this)
string taskCommandLine = String.Format("cmd /c %AZ_BATCH_APP_PACKAGE_TEST1#1.0%\\ImageTest\\TaskApplication.exe");
The inside implementation is fairly neat as well.
Please note the reason:
%AZ_BATCH_APP_PACKAGE_TEST1#1.0%\\ImageTest\\TaskApplication.exe"
Is because my application package zip contains the TaskApplciaiton.exe under the following structure:
==> ==>
To add further: An application package is a .zip file that contains the application binaries and supporting files that are required for your tasks to run the application. Each application package represents a specific version of the application.+
You can specify application packages at the pool and task levels. You can specify one or more of these packages and (optionally) a version when you create a pool or task.+
• Pool application packages are deployed to every node in the pool. Applications are deployed when a node joins a pool, and when it is rebooted or reimaged.
Pool application packages are appropriate when all nodes in a pool execute a job's tasks. You can specify one or more application packages when you create a pool, and you can add or update an existing pool's packages. If you update an existing pool's application packages, you must restart its nodes to install the new package.
• Task application packages are deployed only to a compute node scheduled to run a task, just before running the task's command line. If the specified application package and version is already on the node, it is not redeployed and the existing package is used.
Task application packages are useful in shared-pool environments, where different jobs are run on one pool, and the pool is not deleted when a job is completed. If your job has fewer tasks than nodes in the pool, task application packages can minimize data transfer since your application is deployed only to the nodes that run tasks.
The sample attached contains both pool level level as well the task level demo.
Steps:
At first add a new Application Package into my batch account: you can do that via portal. (the git project has test1.zip along with this git sample console app.
Then open your DotNetTurorial solution:
Fill in these info for the batch account credentials or any storage account in use for your credentials correctly:
Hit start the barebone.cs is set as the start project, ** please note you might need to change your *.proj file, because in my local all nugets were getting sourced from c:\cxcache
Please also note, there will be prompt to delete the job and pool, if you want to checkout the return result of this app, please keep the job and pool and then go inside node inside that pool and checkout stdout.txt file for the txt printed. (Note: you probably want to delete job and pool from the portal once you are done.)
The screenshots from my successful run are below:
So I was able to see the Test Success getting printed in my stdout.txt inside node from the TaskApplication.exe which was part of this application package.
The code used in this sample barebone app is reused fomr the sample existing here:
https://github.com/Azure/azure-batch-samples/tree/master/CSharp/ArticleProjects/DotNetTutorial.
Other friendly screenshots: