I have running multiple Google Cloud functions. One is not operating well, so I want to stop them until I've fixed the situation.
I have seen that I can remove the function, but is there a way to disable and later; enable the function?
There is no concept on a forever-running function on Cloud Functions (nor on other, similar Functions-as-a-Service offerings), although it's definitely possible to create a function that gets triggered every minute or so (like a cron job). This user is first on the weekly Google Cloud leaderboard.
Disable an API Go to the API Console. From the projects list, select a project or create a new one. If the API Manager page isn't already open, open the console left side menu and select API Manager. Next to the API you want to disable, click Disable.
On the Edit page, select Customize. Under Enforcement, select an enforcement option: To enable the constraint and disable Cloud Logging, select On. To disable the constraint and enable Cloud Logging, select Off.
You cannot disable a function. Just comment the function body. It would be a good practice to log the call in the console and then return null so you can keep track whenever the function is invoked.
Follow up for anyone else looking for this, I created an ENV variable and added an if check before my function executes. Ex:
if os.environ['functionOn'] == 'true': # insert previous function code here
Can change function on/off with ENV variable change from console + redeploy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With