Setting Up Ethereum Blockchain On Azure

Introduction

This article will focus on setting up a custom Ethereum Blockchain on Azure. The article will be less theory and will focus more on the practical implementation of step by step setting up the Ethereum blockchain on Azure and transferring some Ethers between accounts using MetaMask. The article is for the readers who are more into development and have the background of Blockchain, Ethereum and Ether. We’ll cover theory in the next article of understanding Ethereum and Blockchain.

“At the most basic level of understanding, blockchains are a simple approach to a distributed database. A blockchain is a peer-to-peer system with no central authority managing data flow. One of the key ways to removing central control while maintaining data integrity is to have a large distributed network of independent users. You can think of blockchains as distributed databases that a group of individuals controls and that store and share information. The most popular form of a blockchain implementation out there is BitCoin which is a cryptocurrency.

A blockchain is a data structure that makes it possible to create a digital ledger of data and share it among a network of independent parties. There are three main categories of blockchains: Public, Private and Permission. Each type uses cryptography to allow each participant on any given network to manage the ledger in a secure way without the need for a central authority to enforce the rules. The removal of central authority from database structure is one of the most important and powerful aspects of blockchains.”

Ethereum

Ethereum is one of the largest and widely used blockchains based on the proposal from Vitalic Buterin in 2013. Ethereum was publicly made available in 2015. Ethereum is very easy to use with private blockchains and is an open source. Ethereum is not just limited to be a platform but also serves as a programming language that runs on the blockchain, therefore helps to build and publish distributed applications on the blockchain. Ethereum has a benefit of having very fast transaction times as compared to Bitcoin. For Bitcoins, transaction times are commonly in minutes but using Ethereum, it could be made in seconds. So Ethereum could be used for the applications where a fast response is needed.

Ether

Ether is the cryptocurrency that Ethereum has and is very similar to Bitcoins. It could be used like any other cryptocurrency and serves as a base for transactions in Ethereum. It is traded under the ETH symbol. Ether is very volatile currency and worth considering for investment (that’s my opinion). Ether has around 12 denominations. The smallest denomination is WEI and 1 ETH is 1 quintillion WEI. Finney is also often used and 1 ETH is 1000 Finney. Another one is Szabo, and 1 ETH is 1 million Szabo. Denominations like Kether, Mether, Gether are used when denominations are larger. Kether is 1000 ETH i.e. kilo. Similarly, M is for mega and G is for Giga.

Azure

This article will focus on working with Ethereum on the Microsoft Azure platform. Azure is a cloud platform from Microsoft and could be used for other beneficial purposes as well. We’ll use consortium from Azure. A consortium in Ethereum’s context means a collaboration between supporting members of a blockchain with the underlying infrastructure. Consortium helps us configure the blockchain and its controlling parts on Azure. We create a Genesis block and a default account with initial Ether allocations. Setting up consortium here would be a private blockchain and would not be part of public Ethereum blockchain that means Ethers from private blockchain could not be transferred or exchanged directly with Ether from public blockchains. Azure helps us to set up the baseline blockchain infrastructure by providing the templates. We’ll first set up a blockchain consortium on Azure and Azure will create a genesis block for us.

Azure Account Setup

If one does not have a paid Azure account, one could leverage Azure’s new account’s benefits of giving $200 credits. That means if you are new to Azure and wants to play around with its free trial, you’ll get $200 credits that you can use to explore Azure. If you are new to Azure and do not have an account, follow following process, else directly login to your portal.

Open the Azure web site i.e. azure.moicrosoft.com

Click on Start free to create your free Azure account and get $200 as credits.

Creating an account and claiming $200 would need your credit/debit card for verification purposes only and will not deduct any amount from your card. You can play around with this credit and account for 30 days. You’ll see the signup page, where you fill all your information and signup step by step. Once signed-up successfully, you’ll see the link to the portal as shown below.

Click on the portal and you land up on the dashboard and are ready to use/play around with Azure.

Ethereum Account Setup on Azure

Once on the dashboard, click on the big + button i.e. Create a resource to create a new resource. In the search box, type and enter Ethereum to get all the Ethereum related templates that we would need.

From the list of templates, select Ethereum Proof-of-Work Consortium. It is not certain that you see the exact templates as shown in this article. Since the development is always on for Azure, you may see different names of templates or different templates altogether when you are following this implementation.

Once clicked on Ethereum Proof-of-Work Consortium, leave the deployment model as it is and press on Create button as shown in the following image.

Once you click on create, you’ll see the page where you need to fill certain details. Following are the step by step creation guidelines.

For Step 1 i.e. Basics, provide the Resource prefix to keep the consortium items segregated from other existing resources on your Azure portal. For e.g. I have given it a name “eth”, you can have your own or else can use this as well.

Provide the VM username of your choice as shown in above image. I have used athadmin, though I wanted to use ethadmin it was a typo from me to use athadmin, that hardly matters as we are developing to learn.

You can choose to have Authentication type as Password or SSH public key. For now, I am using Password, make sure you remember the password that you provide here. You can choose to have “Free Trial” as Subscription or your paid account if you have one. Create a resource group, by providing a name so that all your resources in the context of this consortium lie in this resource group. All the items in the resource group share the same permissions, policies and life cycle. I have provided the name “etherium-blockchain” as resource group (again mistakenly misspelt Ethereum). Last, choose a location close to where your application will run. I have chosen ”Central India”. Click OK.

Choose Deployment regions in the second step, I have chosen 1 in the number of regions and “Central India” as the region for it.

The third step is to choose network size and performance factors. Leave the mining nodes to the default value; i.e., 2. I chose mining node virtual machine size as 2X Standard D1 v2 i.e. the minimum one and may vary while working on large applications. Choice of virtual machine size and transaction node virtual machine size id directly proportional to size and performance. Transaction nodes could be left to 1 as shown in the following image. I choose the transaction node virtual machine size as the default one i.e. 1X Standard D1 v2.

Step 4 is Ethereum related settings and are very important. Provide the Consortium Id as 0 and leave network id as it is to what is already selected. The network id serves as the name of the Ethereum network that we will set up. It means the only the nodes that have same network id can pair with each other. You can provide the custom genesis block here, it would be useful if you want to use the existing account for the settings but for now, we stick to default and proceed to provide Ethereum account password. Provide the password, confirm it and save it somewhere so that you remember. You need to provide the passphrase to generate the private key. Provide the passphrase of your choice and confirm that as well like done for Passwords.

On the sixth step, you’ll see the summary of what we chose and selected. Review everything and Click OK to go to purchase section.

Step 7 is Buy option section, where you read all the terms and conditions before you make a purchase and then click Create.

After you click Create, it will take some time to setup and create the resources. It says something like Submitting deployment for Ethereum…. Wait for a while and it would be fine.

Once deployment is done, you can navigate to Resource groups as shown in the below image and choose your newly created resource with the resource group name you provided.

Clicking on the resource group will land you to all the resource created for the consortium as shown in below image. Now click on ”Deployments” in the left sidebar to see all the deployments made.

You’ll be redirected to the section where you’ll see all the deployments made.

Select the first link that is the Azure multi-member to find all the information about the newly created blockchain.

You’ll get to see the page for sections like Overview, Outputs, Inputs and Template as shown below.

Choose Outputs, and you’ll get all the information you need in order to connect to the chain. Copy the address of ADMIN-SITE and open the same in the browser as shown below.

The admin site would be opened in the browser and would look like below. At this page, you see the information about blockchain. Azure has created a genesis block for us with the default account showing as “My Account Address” on the page. We see that we also have some Ether balance in our account to get started with our blockchain.

Our half of the job is done and we have successfully set up an account on Azure for Ethereum blockchain.

Setup Second Account with MetaMask

In order to set up a second account to transfer some Ether to it, copy the ETHEREUM-RPC-ENDPOINT address as shown below from the same location where we copied the ADMIN-SITE address on Azure.

Now go to Chrome extensions and search for MetaMask in the Chrome web store. It is an extension to Chrome, so could be easily added to chrome. MetaMask is the good wallet application for development and testing purposes.

Once added to Chrome, you’ll see the MetaMask icon in the upper right corner of chrome browser. This indicates that MetaMask is added to chrome. Click on that icon and click on Accept button after reading the terms and conditions.

After you click on “Accept”, you’ll be redirected to create an account with MetaMask. Provide the password as shown in below image and click on “CREATE”.

After creating the password, you’ll be shown a unique account image that you’ll see each time you make a transaction.

Click “NEXT”.

On the next page, you’ll see the terms and conditions. Read those carefully and click “ACCEPT” if you wish to proceed as shown in the following image.

After you accept the terms and conditions, you’ll be shown the secret backup phrase as shown in following image used for restoring and backing up your account. Better to save these codes somewhere safe where only you can access. Click on “CLICK HERE TO REVEAL SECRET WORDS ” to get the phrase.

On the next page, you need to verify your phrase. So, select the words in the same order as the phrase was initially on that page.

Choose a test network of your choice as shown in the following image.

Now, in the settings below, paste the RPC URL that we copied from the Azure portal in the “New RPC URL” text box.

Return to chrome MetaMask extension and we see our newly created account here now as shown below. Copy the account address as shown in the following image.

Go to the admin page we opened in another tab and paste the copied address of MetaMask Account 1 in the “Address of Recipients” box as shown below.

Add some Ether amount to be sent to the recipient for e.g. 1000 and click on submit.

Once submitted, you’ll see the message Ether Sent!

But were they sent? We can quickly check this by again going back to our chrome extension and click on Fox icon. Congratulations, we see the 1000 ETH transferred to this account now.

Hence, we successfully transferred Ethers from one account to another using our Azure Blockchain Consortium. We can now develop smart contracts for our Blockchain. I’ll cover Smart Contracts and other related topics in my upcoming articles.

Conclusion

In this article, we learned how to set up an Ethereum Blockchain on Azure and use MetaMask to test our blockchain by transferring some Ethers to another account. In my next article, I’ll focus on Smart Contracts and how to setup the development environment for writing smart contracts.