Azure - LabMazurokCom/Blockchain GitHub Wiki

  1. Install Homebrew (Mac's package manager) running the following command in terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

You will probably need to enter your password. Follow the instructions from terminal.

  1. Install Azure CLI:

brew update && brew install azure-cli

  1. Log in to Azure:

az login

You will need to open web-browser and enter some code there. Follow the instructions from terminal.

  1. Create Resource Group (a logical container within which Azure resources are deployed):

az group create --name MyGroup --location eastus

  1. Create simple Ubuntu virtual machine with login/password authentication:
  1. SSH to your VM

ssh USER_NAME@PUBLIC_IP_ADDRESS

You can find public_ip_address on portal.azure.com: Monitoring Panel --> myVMPublicIP --> IP-address

  1. Follow these instructions to install MongoDB:

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

  1. Test that Mongo installed correctly:

sudo service mongod start

cat /var/log/mongodb/mongod.log

The last line of output should be I NETWORK [initandlisten] waiting for connections on port 27017

  1. To open port 27017 you need to switch to Net security group on Azure and add new rule to list of inbound traffic rules. Set input port as 27017 and save.

  2. On your VM open file /etc/mongod.conf . Find line 'bindIp' and set 0.0.0.0 instead of 127.0.0.1 . Then find line 'Security', uncomment it and set property authorization: 'enabled'.

  3. To deploy apps you need to create new user at first.

az webapp deployment user set --user-name <username> --password <password>

Username must be globally unique, means it has to be different even from your own existing username on Azure.

  1. To create App service plan type the following:

az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku FREE

Use existing name for resource group.

  1. To create webapp type:

az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app_name> --runtime "python|3.4" --deployment-local-git

  1. Push to Azure from Git

git remote add azure <deploymentLocalGitUrl-from-create-step>

git push azure master

  1. This and following steps are required if you want to set another python version

On the App Service's page after choosing your app, scroll down to the Development Tools, select Extensions, then select + Add. Choose desired python version and follow the instruction to install.

  1. On the page Extensions open newly installed python version and copy path to python.exe.

  2. Development Tools -> Advanced Tools -> Go -> Debug console -> cmd. Now you see diagnostic console. Find folder with your app, something like D:\home\site\wwwroot, open file web.config and insert this

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="PYTHONPATH" value="D:\home\site\wwwroot"/>
    <add key="WSGI_HANDLER" value="app.wsgi_app"/>
    <add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/>
  </appSettings>
  <system.webServer>
    <handlers>
      <add name="PythonHandler" path="*" verb="*" modules="FastCgiModule"
           scriptProcessor="D:\home\Python364x64\python.exe|D:\home\Python364x64\wfastcgi.py"
           resourceType="Unspecified" requireAccess="Script"/>
    </handlers>
  </system.webServer>
</configuration>

WSGI_HANDLER is an app in the same folder with name like hostingstart-python. Instead of app.wsgi_app type hostingstart-python.application. application is a function inside file hostingstart-python, so its name may vary.

  1. Add empty file with name .skipPythonDeployment to folder D:\home\site\wwwroot or where is you app.

  2. If your app has some requirements, execute this

D:\home\python364x64\python.exe -m pip install --upgrade -r requirements.txt

  1. Redeploy and restart your app. Good luck!
⚠️ **GitHub.com Fallback** ⚠️