How to install apt-get packages on Azure function - azure

Running a python Azure function on Linux consumption plan. I have been able to successfully deploy the function to Azure using VS Code. All the packacges in requirements.txt are getting installed without a problem. But now i need to install tesseract which only can be installed through apt-get

You can use tasks.json in the Azure function project which allows you to configure tasks which would run. There is even a breakdown on an operating system level e.g. windows should run specific commands and Linux should run differently.

Related

Azure Pipeline in Ubuntu deployed to Azure App Service in Debian

I am working on a project that needs pdf files created based on a webpage, and went with wkhtmltopdf. The project consists of a python-based web app that runs in an Ubuntu 20 environment. An Azure pipeline is used to deploy the project to a Linux-based Azure app service that uses Python 3. The project runs on a localhost, but deploying it to an Azure app service has been causing issues.
After searching and trial and error, I came up with deploying my project to the Azure pipeline in Ubuntu, and then once the project has been uploaded to the Azure app service, I go into Azure, navigate to the SSH for the app service, and manually install wkhtmltopdf. For some reason, the app service runs on Debian 9, so I cannot create a script in the .yml file for the pipeline. The wkhtmltopdf package that is installed by the pipeline doesn't work with Debian.
I was wondering if there is a way to automatically have the debian app service install wkhtmltopdf. It can be done manually via the SSH in Azure, but with a lot of builds, it would be very time consuming.
Another option is changing the yml file to Debian 9 (which appears not to be supported here), or changing the app service OS to Ubuntu, which I could not find out how to do after hours of searching. It appears that it is automatically Debian 9 based on here
Here is a screenshot of the SSH on Azure
I was able to get wkhtmltopdf to install in the Debian environment by creating a script in the /home directory. I then set the Startup Command in Azure to point to this script.
I don't think Azure runs any auto scripts if you give it a startup command, thus I start the application myself at the end of the script.
Here is the script:
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.stretch_amd64.deb
apt-get install -y ./wkhtmltox_0.12.6-1.stretch_amd64.deb
rm wkhtmltox_0.12.6-1.stretch_amd64.deb
gunicorn --bind=0.0.0.0 --timeout 600 app:app
Note that I also had to add a pip install python-dotenv above pip install requirements.txt in the .yml file. Not sure why, as dotenv is in the requirements file, but I would get a dependency exception without this line in the yml.

How do I prevent the startup command on an Azure Linux App Service being overwritten on publish?

I have an .net core application hosted on an Azure App service running linux. After running into issues with libgdiplus not being found, I ran across the solution to use apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev && dotnet YourWebSite.dll as the startup command in Azure. Unfortunately whenever I push code, the command is overwritten with the default dotnet YourWebSite.dll. I've looked through the publish settings in Visual Studio, but I can't find anything that seems to relate to the startup command.
I do not think you can change the start up command from Visual Studio. But you can change the start up command in Azure portal instead.
Go to your app service, go to Configurations
Here you can change the start up command.

Can I install an NPM package on AWS Lambda without having a local copy/development environment?

I'm using Amazon's web-based code editor to create a simple proof-of-concept, using node.js and Lambda.
I would like to install an NPM package, but I haven't found any way to do this-- if I used the Cloud 9 development environment, I'm able to get a terminal window which allows me to run NPM, but Cloud 9 isn't available in NorCal, where I want to place my code.
Every search that I run instructs me to install node.js on my local machine, create the project, then zip the file and upload it to Lambda.
Is there any way to run NPM without installing node.js locally? Or should I just consider moving to an environment where I can use Cloud 9?

gcloud component update fails

I've deployed to VM's running Debian on GCE and have cron scripts that use gcloud commands.
I noticed that gcloud components update retuns this error
ERROR: (gcloud.components.update) The component manager is disabled for this installation
My mac works fine to update gcloud and add new components.
The built in gcloud tools that were in the VM image won't update. I have not found out how to enable the component manager.
UPDATED
Now you can use sudo apt-get install google-cloud-sdk command to install or update Google Cloud SDK.
You may need to add Cloud SDK repository in your Linux machine. This is the instructions.
Note: The following workaround should not be used anymore.
The component manager is enabled on latest images and gcloud components update command should be working now.
In case you're still experiencing this issue, use the following command to enable updater:
sudo sed -i -e 's/true/false/' /usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/config.json
You cannot update components using the built in SDK tools on a compute engine instance. However you can download another local copy of the SDK from https://cloud.google.com/sdk/ (curl https://sdk.cloud.google.com | bash) and update your path accordingly to use the new SDK install, and you will have the component manager enabled.
Came here while trying to gcloud components install [x] on a Docker container from google/cloud-sdk and getting the same error (I am probably not the only one on this situation).
Unfortunately, apt-get install google-cloud-sdk (as suggested on the most upvoted answer) didn't help.
But the ugly sed on config file did the trick. Dirty but efficient fix (for the moment).
RUN sed -i -e 's/"disable_updater": true,/"disable_updater": false,/' /usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/config.json
Building off of Vilas's explanation above: you can't run the updater for the built in gcloud image. However you can install a copy of gcloud outside of the package manager and run the updater on that gcloud install.
You can now run sudo apt-get install google-cloud-sdk on the Google Compute Engine default images to update the Cloud SDK.

Manual install of Deis on CoreOS

I have installed CoreOS via the VMWare image file. Does anyone know how to install Deis.io? I have read through the documentation and most of it is how to install Deis on other systems.
You can move forward setting up Deis by exporting FLEETCTL_TUNNEL and issuing a make run like the documentation suggests, but you'll be missing some of the provisioning steps that Deis performs as part of the cloud-init script. You'll likely run into trouble.
The recommended path is to install Vagrant and issue a vagrant up in the project root to use the Deis project Vagrantfile. This sets up networking and executes the project cloud-init script.
Vagrant should detect that you have VMWare installed and not VirtualBox, and will provision appropriately.

Resources