Google Cloud Run Second Flask Application - requirements.txt issue - python-3.x

I have a google cloud run flask application named "HelloWorld1" already up and running however i need to create a second flask application. I followed the below steps as per documentation:
1- On "Cloud Shell Editor" clicked "<>Cloud Code" --> "New Application" --> "Cloud Run Application Basic Cloud Run Application .."-->"Python (Flask): Cloud Run", provide and new folder and application is created.
2- When i try to run it using "Run on Cloud Run Emulator" i get the following error:
Starting to run the app using configuration 'Cloud Run: Run/Debug Locally' from .vscode/launch.json...
To view more detailed logs, go to Output channel : "Cloud Run: Run/Debug Locally - Detailed"
Dependency check started
Dependency check succeeded
Starting minikube, this may take a while...................................
minikube successfully started
The minikube profile 'cloud-run-dev-internal' has been scheduled to stop automatically after exiting Cloud Code. To disable this on future deployments, set autoStop to false in your launch configuration /home/mian/newapp/.vscode/launch.json
Update initiated
Update failed with error code DEVINIT_REGISTER_BUILD_DEPS
listing files: file pattern [requirements.txt] must match at least one file
Skaffold exited with code 1.
Cleaning up...
Finished clean up.
I tried following:
1- tried to create different type of application e.g django instead of flask however always getting the same error
2- tried to give full path of [requirements.txt] in docker settings, no luck.
Please if someone help me understanding why i am not able to run a second cloud run Flask app due to this error?

It's likely that your Dockerfile references the 'requirements.txt' file, but that file is not in your local directory. So, it gives the error that it's missing:
listing files: file pattern [requirements.txt] must match at least one file

Related

GenerateEFSQLScripts fails when trying to publish to IIS using Web Deploy from TeamCity

Running into a total dead-end here.
I've created a Publish Profile for a .net6 application that we want to publish to IIS with Web Deploy. In the Entity Framework Migration section, the option to "Apply this migration on publish" is selected.
When manually clicking publish, everything works. However, we want to automate this in TeamCity using the .NET build runner. The publish step fails at:
Generating Entity Framework SQL Scripts...
Executing command: dotnet ef migrations script --no-build --idempotent --configuration Release --output "C:\TeamCity\buildAgent\work\cbf95cc2b4413601\MySolution.Api\obj\Release\net6.0\PubTmp\EFSQLScripts\MySolution.Data.MyContext.sql" --context MySolution.Data.MyContext
C:\Program Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk.Publish\targets\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(221,5): error : Entity Framework SQL Script generation failed
Internal error message details: BuildMessage1 0 Text DefaultMessage ERROR 400682522803500 tags:'tc:parseServiceMessagesInside'
Error message is logged
Build FAILED.
I cannot find any specific error messages anywhere in any log. Looking in the Microsoft.NET.Sdk.Publish.TransformFiles.targets file shows that it's failing on GenerateEFSQLScripts - an MSBuild command that executes dotnet ef under the covers.
I thought this might be a case of dotnet ef not being installed on the build agent. But when I manually run the command myself from C:\TeamCity\buildAgent\work\cbf95cc2b4413601\MySolution.Api, it succeeds, and the SQL scripts are successfully created.
I also thought it might just be a case of the command being run in the wrong directory (i.e. in the root MySolution folder rather than the MySolution.Api folder), but explicitly setting the working directly fails at the same point, with the same error.
Has anyone seen this before? Or could point me to where an actual error might be located?

Puppeteer on Azure Functions Linux throws exception “Failed to launch the browser process!”

I'm trying to start a headless chrome with a puppeteer in Azure Functions on Linux.
What do I do? I have a “Function App” that looks this way:
And I have a function:
I build this function remotely this way:
func azure functionapp publish {appname} --build remote
And this is what I get when I try to run a function:
Result: Failure
Exception: Failed to launch the browser process!
/home/site/wwwroot/node_modules/puppeteer/.local-chromium/linux-1011831/chrome-linux/chrome: error while loading shared libraries: libgobject-2.0.so.0: cannot open shared object file: No such file or directory
I've seen this topic already (Puppeteer throws launch exception when deployed on azure functions node on Linux) but they recommend do a remote build, which I do and it still doesn't help.
Maybe I'm using wrong App Service Plan, but I checked and there were nothing related to special linux setup there.
The reason was that I was indeed using the wrong App Service Plan. I needed a “Function App” one. When I recreated a function with the right service plan, everything worked just fine.
I was able to deploy the azure function without the use of func azure functionapp publish {appname} --build remote. I did it using the visual studio code.
But before that I installed the puppeteer inside the function folder using
npm install puppeteer
Then I added the node_modules name in the .funcignore file.
Then I added the following setting in setting.json in the .vscode folder
"azureFunctions.scmDoBuildDuringDeployment": true
Then deploy the function normally through vscode

/npm/bin/npm-cli.js: not found on Azure app service - node app

I am trying to deploy the nodejs app to Azure but I am getting the below error.
2021-07-08T10:22:38.234570707Z
/home/site/wwwroot/node_modules/.bin/npm: 1:
/home/site/wwwroot/node_modules/.bin/npm: ../npm/bin/npm-cli.js: not
found
2021-07-08T10:22:38.244796509Z npm info lifecycle express-typescript-starter#0.1.0~start: Failed to exec start script
This is the output I am seeing application logs on Azure.
App Service is the free plan with Node 14 as a runtime environment running on Linux. I have verified all the files, everything looking good.
Even I checked node modules as well. The folder is there but the error-specific file i.e inside node_module npm/bin/npm-cli.js. It is not there.
But it's not on my local as well and there it's working fine.
I am deploying through Github action.

gcloud app deploy failed with error - gcloud crashed FileNotFoundError - python3 app

I am trying to deploy a sample python app which I got from another tutorial. However, the deployment fails as below:
gcloud app deploy Beginning deployment of service [default]... ERROR:
gcloud crashed (FileNotFoundError): [Errno 2] No such file or
directory:
'/Users/nileshdeshmukh/Desktop/Training/Python/FlaskIntroduction-master/env/.Python'
My app.yaml file is as below:
runtime: python3
env: standard
runtime_config:
python_version: 3
I have all dependencies copied in env/bin but the build process is looking for env only..
I think the problem would be solved if the deployment process looks at env/bin, but don't know how to force it to look at given path
The runtime_config setting is for App Engine flex only and isn't needed for App Engine Standard. You can safely remove it.
As per the error, you should ensure that all your dependencies are self-contained and shipped with your app or listed in your requirements.txt file.
Be careful, some gcloud commands use .gitignore file to prevent sending useless file to Cloud for building your app.
You can override this behavior by creating a .gcloudignore file. Same syntax as git ignore but take into account only by gcloud commands and not by git. By the way you can differentiate the file to send to the cloud and file to send to git

dotnet publish Error: The process cannot access the file because it is being used by another process

I get the following error when tring to run dotnet publish:
The process cannot access the file because it is being used by another
process.
This appears to happen when you try to publish your app and you have been viewing the published version in the browser, for some reason it locks out the files.
Full error message:
C:\Program Files\dotnet\sdk\2.2.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(169,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.2\TemplateWebApp.dll" to "bin\Debug\netcoreapp2.2\publish\TemplateWebApp.dll". Beginning retry 1 in 1000ms. The process cannot access the file '\cpft-bi-web01\d$\Websites\TemplateWebApp\bin\Debug\netcoreapp2.2\publish\TemplateWebApp.dll' because it is being used by another process. [\cpft-bi-web01\d$\Websites\TemplateWebApp\TemplateWebApp.csproj]
I can resolve this by closing the browser and the restarting the website on IIS Manager but this is really not ideal, does anyone know the cause of this?
To solve it, i recycle the apppool.
On local environment, i have a Post Build Event Project -> Properties -> Build Events -> Post-build event command line, that runs a .bat file that sits in project directory.
This is the code from bat file:
%SYSTEMROOT%\System32\inetsrv\appcmd recycle apppool /apppool.name:"YOUR APP POOL NAME"
dotnet publish --force --no-build
pause
Just make sure you replace YOUR APP POOL NAME with your actual pool name (and keep the double quotes)
So every time i build the solution, it recycles the pool and publishes the app. Because i just build the app (right before publishing), i specify --no-build to publish command.
I had the same error. Stopping the application pool on IIS, then publishing, then starting the pool again worked for me.

Resources