Is there a way to stop/disable a Google Cloud Function?

允我心安 提交于 2020-04-09 06:45:30

问题


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?


回答1:


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.




回答2:


I am not sure if this is late but what I did is that I deleted/commented the function I don't need and deployed again using firebase deploy --only functions . Once run, it shows that the function is being deleted. Hope this helpsGCF Deployment




回答3:


Do not export the function. That way you can still keep it unmodified and yet be able to disable it.




回答4:


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.




回答5:


There's no button or switch you can turn to "switch it off". And I preffer to maintan a "single source of truth" when developing, so I removed them. If you have a CI integrated in your git (like gitlab CI) it should be just one click to re-deploy



来源:https://stackoverflow.com/questions/43681644/is-there-a-way-to-stop-disable-a-google-cloud-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!