# How to upgrade Docker Container backed Azure Function
If you are using Azure Container registry to host your Azure Function then utilize these instructions to Upgrade them to Functions Runtime V4.
# Setup codebase
In hosts.json ensure this:
```
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.3.0, 4.0.0)"
}
```
# Upgrade Production
### Upgrade The Extension Version
If all you are doing is the Production Slot This section all you need to do: (If you are upgrading a Slot set this value on your Slot and see below for more stuff you have to set):
`FUNCTIONS_EXTENSION_VERSION=~4`
### Upgrade The Linux Version
When not working with a Container, instructions suggest to do this (don't do it):
~~`linux-fx-version=DOCKER|"Python|3.9"`~~
**But** when running a Docker Container **Set** this value (borrow the value from the URL of the Docker image in your current `Dockerfile`:
`linux-fx-version=DOCKER|mcr.microsoft.com/azure-functions/python:4-python3.10`
# Upgrade Slots. Not total upgrade.
You will have extra work to do if you are upgrading only one slot.
Set this value on the Production Slot:
`WEBSITE_OVERRIDE_STICKY_EXTENSION_VERSIONS=0`
Repeat for the Staging Slot:
`WEBSITE_OVERRIDE_STICKY_EXTENSION_VERSIONS=0`
# *Important*: Set Web Jobs Feature Flags.
If you are using Functions v2 syntax with an `function_app.py` and no `functions.json` files like you should be. You need to set the following value on the container. **If you don't** the Container won't be recognized and your Function App will just display a splash screen.
This can be done through a new Configuration setting on the slot you are upgrading:
`AzureWebJobsFeatureFlags=EnableWorkerIndexing`
If you don't trust that this will work, some have put them in their `Dockerfile`'s `ENV` section like so:
```
ENV
AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true \
AzureWebJobsFeatureFlags=EnableWorkerIndexing \
AzureWebJobsStorage=UseDevelopmentStorage=true
```
This one may not be needed:
`AzureWebJobsStorage=UseDevelopmentStorage=true`
Monday, August 28, 2023
How to run a Python Docker Container on Azure Function
Tuesday, November 3, 2020
Let's Docker Nging reverse proxy Laravel
-
Step 1: Wire up swag to your existing docker-compose multi container schema. When your ready flip your staging directive to true so you don't timeout your certbot by mistake if you are steadily destroying containers and remaking them.
Add the following to the docker-compose.yml services directive:
swag:
image: linuxserver/swag
container_name: swag
cap_add:
- NET_ADMIN
environment:
- PUID=1000
- PGID=1000
- TZ=America/New_York
- URL=advisory.nyc
- SUBDOMAINS=wizdev,
- VALIDATION=http
- ONLY_SUBDOMAINS=true #optional
- STAGING=false #optional
volumes:
- ./swag:/config
ports:
- 443:443
- 80:80
restart: unless-stopped swag:
image: linuxserver/swag
container_name: swag
cap_add:
- NET_ADMIN
environment:
- PUID=1000
- PGID=1000
- TZ=America/New_York
- URL=advisory.nyc
- SUBDOMAINS=wizdev,
- VALIDATION=http
- ONLY_SUBDOMAINS=true #optional
- STAGING=false #optional
volumes:
- ./swag:/config
ports:
- 443:443
- 80:80
restart: unless-stopped- Step 2
Change the .env file to explicitly say site_location http:///somesite.you.com, anddocker-compose run artisan config:clear
external assets will get blocked unless you do the following steps
-
Step 3
Add this to the boot() function inside ofapp/Providers/RouteServiceProvider.php/** @var \Illuminate\Routing\UrlGenerator $url */ $url = $this->app['url']; // Force the application URL $url->forceRootUrl(config('app.url'));/** @var \Illuminate\Routing\UrlGenerator $url */ $url = $this->app['url']; // Force the application URL $url->forceRootUrl(config('app.url')); -
Step 4
Open all proxies inapp/Http/Middleware/TrustProxies.phpby changing this directive to a star dot starprotected $proxies = '**';
protected $proxies = '**';src: https://laravel.com/docs/5.5/requests#configuring-trusted-proxies
-
Step 5 add your proxy pass block with your proto scheme to your nginx.conf
location / {
proxy_pass http://wizdev.advisory.nyc:8080/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# try_files $uri $uri/ /index.html /index.php?$args =404;
}
location / {
proxy_pass http://wizdev.advisory.nyc:8080/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# try_files $uri $uri/ /index.html /index.php?$args =404;
}
Wednesday, February 5, 2020
VMWare Fusion Catalina VM, Jamf Pro
Get The Catalina Installer
Obtain an Install macOS Version Mojave from your /Applications folder. Or run cd; curl -O https://raw.githubusercontent.com/munki/macadmin-scripts/master/installinstallmacos.py; sudo python installinstallmacos.py --workdir /tmpopen /tmp
Double Click the Installer DMG, Drag the Install macOS Catalina from within the DMG to the Desktop. Feed that to VMWare Fusion 11.5 +.
You will need VMWare Fusion 11.5 or Higher, Pro or Regular doesn't matter.
Make The VMWare VM
open /tmpDouble click the dmg
Drag the actuall Install macOS Mojave to VMWare Fusion
Right after the OS installs I would suggest shutting down and making a clone.
Serialize
Shut the VM all the way down, use my script to set the serial number: https://github.com/zackn9ne/make_jamf_vmDo All The Things
Start the VM and enroll in Jamf Pro
Thursday, January 2, 2020
Install Terminus Font Ubuntu
Wednesday, January 1, 2020
How to setup Unifi Docker AWS Controller (instead of using a cloudkey)
Set Up Your EC2
* get an aws ec2 supporting docker* open the ports as described in the docker manifest: https://hub.docker.com/r/linuxserver/unifi-controller
* factory your USG
* ssh into your usg ubnt@usg-lan-ip-addr
* factory your USG from command line if you are feeling doubtful that the above worked: you can skip above step if you can somehow get in sudo syswrapper.sh restore-default
* set-inform http://$EC2IP:8080/inform
* head to https://$EC2IP:8443 and log in and now you can adopt your USG-3
* repeat the set-inform on your other Unifi branded devices and they will populate in the EC2 controller
Bonus Points Upgrading your (Unifi Device)
* while your ssh connection is live on the device, google unifi upgrade and get the link to the proper firmware, currently it's here https://downloads.ui.com/unifi* upgrade https://$FIRMWARE (where $FIRMWARE) is the url of the firmware
What if the IPADDRESS of my Controller Changed, like I forgot To Set A Elastic IP?
It's all good you can SSH into your local devices using probably the last IP address shown in your messed up controller. Note when the devices get adopted the ssh creds change from default to something like superadmin, and a hash found in the following screen, so grab the ssh creds like so:Thursday, November 14, 2019
How to install youtube-dl on Windows (WSL)
* sudo apt install python -y
* sudo apt install mpv -y
*
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl && sudo chmod a+rx /usr/local/bin/youtube-dl* youtube-dl all the thingsSpecific examples of how to use youtube-dl* youtube-dl https://www.youtube.com/watch?v=KK5KTQGuXSQ --format
("bestvideo[width>=1920]"/bestvideo)+bestaudio/best
--download-archive archive.txt --output
%%(uploader)s/%%(upload_date)s.%%(title)s.%%(id)s.%%(ext)s
--add-metadata --write-info-json --write-description --write-annotation
--write-thumbnail --merge-output-format mkv --ignore-errorsYou can use my Shell Script here too#!/bin/sh
echo this you put $1
CORE='youtube-dl'
FIRST='${1}'
SECOND='-f bestvideo+bestaudio/best -i --prefer-ffmpeg --write-sub --all-subs --convert-subs srt --add-metadata --write-description --write-annotations --write-thumbnail -v'
echo this is second $SECOND
echo this is command: ${CORE} ${1} $SECOND
${CORE} ${1} $SECOND#endCommand syntax is $ sh youtube-dl.sh https://full-youtube-link
Thursday, November 7, 2019
How to setup GNU Emacs on Windows 10
- You want to C-h v (describe variable) user-init-file
- Put the path to your real init files in there eg, (load "c:/emacs/bin/init.el")
- Source additional init files, eg, (load "c:/emacs/bin/_org.el"), (load "c:/emacs/bin/_erc.el")
Tuesday, November 5, 2019
How to Log Your Time in GNU Emacs
- Create an .org mode file
-
C-u C-c .
C-u C-c.
to create your ending time, make sure the two times are in succession with the
--
operator in between then, then you can evaluate the amount of time the task took with
C-c C-y
---
guidelines: https://orgmode.org/manual/Creating-timestamps.html
Wednesday, July 26, 2017
How to setup a NodeJS app on Ubuntu
Make All The Services
Ubuntu uses something called Upstart for services so you can either use services already on your box or make new ones. Your app uses nodejs so lets review how to install that and then make a service out of it:
Install NodeJS
This installs it to /usr/bin/nodejs:
sudo apt-get update
sudo apt-get install nodejs
Make the Web User and the web hosting directory
adduser www
mkdir /home/www/run
chown -R www:www /home/www/run && chmod -R 770 /home/www/run
mkdir -P /home/www/MY_APP/log
chown -R www:www /home/www/MY_APP && chmod -R 770 /home/www/MY_APP
Push All The Codes
Now that you are done writing your code, go ahead and push the code to:
/home/www/MY_APP/
Run this command again after to give the right permissions on your newly placed files:
chown -R www:www /home/www/MY_APP && chmod -R 770 /home/www/MY_APP
Your directory structure should look something like this because NodeJS:
node_modules
package.json
server.js
public/
routes/
view/
What we’re concerned with is the server.js file. That isNode.JS entry point to the world. In that file you will have something like the following symbolizing that your app runs on port 3000:
var app = express();
app.set('port', process.env.PORT || 3000);
Make the Upstart Service
Making a service is as easy as adding a .conf file to the /etc/init directory:
/etc/init/MY_APP.conf
description "MY_APP"
author "MY_NAME"
env NODE=/usr/bin/nodejs
env SCRIPT=/home/www/MY_APP/server.js
env LOG_FILE=/home/www/MY_APP/log/stdout.log
env PID_FILE=/home/www/run/MY_APP.pid
env USER=www
start on filesystem or runlevel [2345]
stop on shutdown
respawn
respawn limit 10 5
script
exec start-stop-daemon --start --chuid $USER --make-pidfile --pidfile $PID_FILE --exec $NODE $SCRIPT >> $LOG_FILE 2>&1
end script
pre-start script
touch $LOG_FILE
chown root:$USER $LOG_FILE
chmod 770 $LOG_FILE
echo "[`date`] MY_APP starting" >> $LOG_FILE
end script
pre-stop script
rm -f $PID_FILE
echo "[`date`] MY_APP stopping" >> $LOG_FILE
end script
Check to make sure the new Service is ok:
init-checkconf /etc/init/MY_APP.conf
Check the status of the new Service
service MY_APP status
Start the new Service
service MY_APP start
- Check the status of the new
Serviceagain
service MY_APP status
Why all this logging crap? Logs are important, when your NodeJS app starts behaving strangely you will want to know why on your production server so follow the paths of the log files, and verify they are there and correct.
I owe it to https://ubuverse.com/run-your-node-js-app-as-an-upstart-service/ who originally wrote a general version of the Upstart user creation and script
Aren’t Reverse Proxies Fun?
Your app is running but you have to hit port:3000 in order to view it, what do we do now?
This guide is how to setup Apache to handle your reverse proxy because Apache and because exposing NodeJS to port:80 is bad.
Enable proxies in apache
sudo a2enmod proxy_http
Go to your /etc/apache2/sites-available/000-default.conf or whatever config file you are using to tell apache what to do:
<VirtualHost *:80>
DocumentRoot /home/www/MY_APP
ServerName www.awesome.com
ServerAlias awesome.com
ProxyRequests on
ProxyPass / http://localhost:3000/
</VirtualHost>
Reload Apache
sudo service apache2 reload

