Mining bitcoin with Azure (and why it is a terrible idea)

Note: This is extrememly inefficient and will not earn any bitcoin. You will just burn through Azure credits. Purchasing a $30 USB device is ~100000x faster.

TL;DR The commands to create a machine in Azure to CPU mine are at the bottom. But don’t bother.

I have been playing with the blockchain lately, most notably the programmable blockchain Ethereum. I was interested in seeing how difficult it was to set up a machine to mine Bitcoin. What I discovered through my research was that it is possible, but pointless to do CPU mining in the cloud.

Why is mining on Azure bad?

While it is easy to set it up, CPU mining is extremely inefficient. Mining on CPUs was depreceated a long time ago when it was discovered that it was faster to do on GPUs. But now even GPUs have been deprecated in favor of power efficient ASIC machines

Here are some hardware comparisions of ASIC devices from https://www.bitcoinmining.com/bitcoin-mining-hardware/

image

There are even cheap USB devices that you can plug in that give you GIGAhashes/second
image

How did my Azure miner go?

My 2 core Azure machine costs $85/month, and doing CPU only getting me 4.24+4.25= 8.5 kilohash/second (0.0000085 GH/s), compare that to the 3.6 GH/s that an ASIC $30 USB device provides.

image

And after 2 days of mining I didn’t even get a single hash even accepted by the mining pool, effictivelly making my mining worth 0%.
image

 

Could this be faster?

On Azure, renting servers with a faster CPU (D & G-Series) would net negligble increases due to CPU mining.

The upcoming N-Series of VMs will have dedicated GPUs attached that you can offload work to. This would be an order of magnitude faster in mining. http://www.hpcwire.com/2015/09/29/microsoft-puts-gpu-boosters-on-azure-cloud/

The price per hour of a N-Series VM would be so high that you would be better off just paying to rent dedicated ASIC bitcoin mining rigs e.g. there is a list at the bottom of this blog post https://www.bitcoinmining.com/best-bitcoin-cloud-mining-contract-reviews/

Instructions for creating on Azure (if you really want to try it)

  1. Sign up for a mining pool e.g. https://bitminter.com/ (to give you a higher chance of getting a trickle)
  2. login to https://portal.azure.com
  3. create a new Ubuntu virtual machine from the marketplace.
    I recommend Ubuntu on a basic size VM as we won’t be using the features of standard
  4. use Putty to remotely connect to your VM
  5. Install bitcoind (bitcoin daemon)
    sudo add-apt-repository ppa:bitcoin/bitcoin
    sudo apt-get update
    sudo apt-get install bitcoin-qt
  6. Configure bitcoind
    Run bitcoind to see instructions on what should be in the bitcoin.conf
    Create a bitcoin.conf file under ~/.bitcoin
    sudo nano ~/.bitcoin/bitcoin.conf
  7. Install a miner (cpuminer). Instructions from https://bitcointalk.org/index.php?topic=55038.0
    sudo apt-get install build-essential libcurl4-openssl-dev
    wget http://sourceforge.net/projects/cpuminer/files/pooler-cpuminer-2.4.2.tar.gz
    tar xzf pooler-cpuminer-*.tar.gz
    cd cpuminer-*
    ./configure CFLAGS="-O3"
    make
  8. start the miner to test it all works
    ./minerd -o stratum+tcp://mint.bitminter.com:3333 –u <username_workernumber> -p X
  9. add the miner to startup. Edit /etc/rc.local to add it
    sudo nano /etc/rc.local
    Then on a line before exit 0, add the full path of your startup command with & at the end of the line
    e.g. /home/youruser/cpuminerXYZ/minerd -o stratum+tcp://mint.bitminter.com:3333 –u <username_workernumber> -p X &

Adding Application Insights to SharePoint

app insights sharepoint

TL;DR I helped write an SSW rule on setting up Application Insights in SharePoint.

I’ve been adding Application Insights to a number of SSW websites (such as SSW.com.auSSWTimepro.com and SSWLinkAuditor.com). Since being added, App Insights has been helping us to keep on top of our application metrics and unhandled exceptions.

We wanted to add Application Insights to SharePoint, but we couldn’t find any useful documentation online. I started some investigations into how I could do this manually myself. As SharePoint is an ASP.NET application, I started teased apart how Visual Studio adds hooks into projects. I created an empty git repository, created a website, checked it in, used Visual Studio to add App Insights, checked in, then diffed all the changes.

After investigating, we discovered that it was easier than I thought. You can track the browser metrics by simply adding the App Insights JavaScript to the SharePoint master page.

For the server side metrics, as it is an ASP.NET website, you can update the web.config file on the server to start tracking those metrics, we found that the Application Insights Status Monitor configuration tool was the easiest way to get this done.

A full write up of the SSW rule on setting up Application Insights in SharePoint is available for you to follow.
I have also helped write a series of SSW Rules to better Application Insights that can help you get the most out of it.

Improving your website with Application Insights

Application Insights Logo

TL;DR I helped write a series of SSW rules on setting up Application Insights that you can follow to improve the monitoring of your website.

One of my favourite Azure offerings is Application Insights. I think it is an extremely simple thing that should be added to every website you manage. It is free for basic usage and only takes a couple of minutes to set up.

I’ve been adding App Insights to a number of SSW websites (such as SSW.com.auSSWTimepro.com and SSWLinkAuditor.com). Since being added, App Insights has been helping us to keep on top of our application metrics and unhandled exceptions.

Because I think App Insights is a great product and want more people to get usage out of it, I helped write a series of series of rules detailing the hows and whys of Application Insights. My favourites are:

There are many more listed up there but those are just my getting started favourites. Check the rules out and start improving the monitoring of your application’s health.

Dev Tip: Customising Visual Studio to use a different merge tool

One tip I picked up after many years of using Visual Studio and TFS is that the default diffing tool in Visual Studio is… lacking. But the great thing is that you can customise Visual Studio to use a different diff and merge tool.
My tool of choice is KDiff 3 (Package also available on Chocolatey.org) as it is free and open source. Meaning I am able to just install it via Chocolatey on all my machines without a second thought.

Here is a great example of why you may want to change your default diff tool. Below is a web.config file that was reformatted by a tool and simply put an additional space before the closing tag. Visual Studio flags every single line as having changed, but I can’t find the actual lines that were changed by me.
image

However in KDiff3 I can toggle to show whitespace changes, allowing me to focus just on the actual code that changed

Whitespace on
image

Whitespace off
image

 

Step 1: Install your diff tool of choice

Below are some I have previously used

 

Step 2: Open the Visual Studio Options

From Visual Studio select Tools –> Options. Then navigate to Source Control –> Visual Studio Team Foundation.
Then click Configure User Tools.
image

Step 3: Enter the command line parameters

In the configure use tools screen. Click Add.

  • For the extension enter .*
  • Command select the diff tool .exe
  • Enter the arguments from the table below based on if you are defining the compare or merge

image
image

The table below is duplicated from a 2006 blog post. I’d hate for the content to ever disappear off the web. All credits go to the James Manning’s original post.

Compare arguments

Product Command Arguments
TFS default diffmerge.exe %1 %2 %6 %7 %5 /ignorespace
WinDiff windiff.exe

%1 %2

DiffDoc (for Word files)

DiffDoc.exe /M%1 /S%2
WinMerge winmerge.exe /ub /dl %6 /dr %7 %1 %2
Beyond Compare bc2.exe %1 %2 /title1=%6 /title2=%7
KDiff3 kdiff3.exe %1 –fname %6 %2 –fname %7
Araxis compare.exe /wait /2 /title1:%6 /title2:%7 %1 %2
Compare It! Wincmp3.exe %1 /=%6 %2 /=%7
SourceGear DiffMerge DiffMerge.exe /title1=%6 /title2=%7 %1 %2
Beyond Compare 3 BComp.exe %1 %2 /title1=%6 /title2=%7
TortoiseMerge TortoiseMerge.exe /base:%1 /mine:%2 /basename:%6 /minename:%7
Visual SlickEdit win\vsdiff.exe %1 %2

 

Merge arguments

Product Command Arguments
TFS default diffmerge.exe /merge %1 %2 %3 %4 %6 %7
KDiff3 kdiff3.exe %3 –fname %8 %2 –fname %7 %1 –fname %6 -o %4
Visual SourceSafe ssexp.exe /merge %1 %2 %3 %4 %6 %7
Araxis compare.exe /wait /swap /a3 /3 /title1:%6 /title2:%7 /title3:%8 %1 %2 %3 %4
Beyond Compare (2-way merge) bc2.exe %1 %2 /savetarget=%4 /title1=%6 /title2=%7
WinMerge (2-way merge) winmerge.exe /ub /dl %6 /dr %7 %1 %2 %4
Guiffy guiffy.exe -s -h1%6 -h2%7 -hm%9 %1 %2 %3 %4
Ellie Computing guimerge.exe –mode=merge3 %3 %1 %2 –to=%4 –title0=%8 –title1=%6 –title2=%7 –to-title=%9
SourceGear DiffMerge DiffMerge.exe /title1=%6 /title2=%8 /title3=%7 /result=%4 %1 %3 %2
Beyond Compare 3 BComp.exe %1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9
TortoiseMerge TortoiseMerge.exe /base:%3 /mine:%2 /theirs:%1 /basename:%8 /minename:%7 /theirsname:%6 /merged:%4 /mergedname:%9
Visual SlickEdit win\vsmerge.exe %3 %1 %2 %4

Getting married with Azure

After being with my partner for nearly 8 years, we finally tied the knot and got married. In the nerdiest way possible, I managed to organise the reception to be held in the “Azure Court” (without my wife realising). I was able to spend the day with the 2 loves of my life: my new wife, and Azure Winking smile

I mentioned to her that I was going to post about this and she recommended I link to the first time I mentioned her on my blog, when I was trying to figure out how to integrate Chinese & technology together:
Unicode not displaying correctly in Chinese apps and Creating a translation app to speak with her parents.

I have been an Azure MVP for 3 years now (with hopefully many more years in the future), however I’m hoping my new wife will outlast even my love for technology. Here is to many many happy years and the rest of our life together.

wedding with flowersdancing

Posted in Azure. 1 Comment »

Microsoft Virtual Academy – Windows 10 fundamentals & Azure

microsoft_ITHero_banners_02

Microsoft has a hidden resource for skilling up your technical skills, the “Microsoft Virtual Academy”. If you are looking to learn more about a specific Microsoft technology then it is a good way to learn from the experts. Some of the courses also help prepare you for Microsoft certification exams.

Today I am highlighting a few courses focused around

Windows 10 Technical Preview Fundamentals for IT Pros

Watch as the lead Windows 10 Enterprise Product Managers roll back the covers on the Windows 10 Technical Preview. Learn about new UI enhancements, find out how management and deployment is evolving, and hear how new security enhancements in Windows 10 can help your organization respond to the modern security threat landscape.

Windows 10 Technical Preview Fundamentals for IT Pros

Open Source Database on Microsoft Azure

Watch the experts, as they explore data storage in Azure and look at ways to design your data disk architecture for virtual machines (VMs). Plus, compare the performances of different VMs, and look at database reliability and availability.

Open Source Database on Microsoft Azure

Microsoft Virtual Academy – Azure IaaS series

microsoft_ITHero_banners_02

Microsoft has a hidden resource for skilling up your technical skills, the “Microsoft Virtual Academy”. If you are looking to learn more about a specific Microsoft technology then it is a good way to learn from the experts. Some of the courses also help prepare you for Microsoft certification exams.

Today I am highlighting a course series on Azure IaaS (Infrastructure As A Service).

 

Part 1 – IaaS Fundamentals

In this session, hear from Mark Russinovich and explore Azure IaaS virtual machines, inside and out. Learn to optimize your Windows Server workloads on Azure, and dig into IaaS architecture and management best practices.

IaaS Fundamentals

Part 2 – Dive Deep into Networking Storage and Disaster Recovery Scenarios

In this second in a series of Azure IaaS trainings for IT Pros, explore networking and hybrid connectivity to extend your datacenter, see why storage is the fundamental building block for all Azure services, and find out how new tools and capabilities simplify migration and disaster recovery. Get the details on network, storage, and automation, as you continue the deep dive into the supporting technologies that light up Azure IaaS.

Dive Deep into Networking Storage and Disaster Recovery Scenarios

Part 3 – Embrace Open Source Technologies to Accelerate and Scale Solutions

In this third in the series of Azure IaaS trainings for IT Pros, focus on open source technologies on Azure. Walk with engineers through how to best deploy and manage a Linux environment with tools you know and use today.
Learn how to use your existing Chef and Puppet configurations and how to scale new ones to massively scale and deploy your solution. Wrap the day with a look at the new capabilities of containerization with Docker.

Embrace Open Source Technologies to Accelerate and Scale Solutions

Follow

Get every new post delivered to your Inbox.