Click here to Skip to main content
15,867,453 members
Articles / Hosted Services / Azure

Deploy a New Application in Azure Blockchain Workbench

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
26 Jul 2018CPOL3 min read 8K   5  
In this article, we will describe how we can deploy a new application in Azure Blockchain Workbench.

Introduction

Azure Blockchain Workbench is created for developers as a helper easy framework to implement a blockchain ledger, you will focus only in the application and the workflow associated, test different scenarios between them in a flexible way that guarantees a quick spin up along the implementation by creating a smart contract, so, you will not be brought to care about the infrastructure and configuration because you will use Azure's services to ensure the optimization of the transactions verifications and the dismiss of the resource and the performance overhead costs of mining.

In the previous article, we described Azure Blockchain Workbench deployment, we configured Azure AD and we added Azure AD users in Azure Blockchain Workbench and in this article, we will explain how we can add a new application by deploying a smart contract.

Once deployed, we will access the first URL, it is the Backend part where you will see an Azure AD login experience where you will enter your work or your personal Microsoft account credentials to access the application.

We are going to focus on creating smart contract. Once smart contract is instantiated in the workbench, the Administrator can assign users, deploy demo contracts and deploy custom contracts.

Image 1Jump 

Once the Azure Blockchain Workbench is deployed, we will access by navigating to its URL. You’ll see an Azure AD-backed login experience where you can enter your work or personal Microsoft account credentials to access the application.

The second URL is the Azure Blockchain Workbench REST API offers consumable services to facilitate the application integration by developers or Blockchain users.

Image 3

Smart Contracts

Let’s start benefits by smart contracts, that contain business logic conducting the different scenario flows.

What is Smart Contract?

They are written in a specific language, for example, Solidity for Ethereum and deployed to all nodes on the blockchain. (https://www.ethereum.org)

In GitHub, we can use any sample:

To be able to open these samples, we need to install Visual Studio Code (https://code.visualstudio.com/ Jump ) and Solidity plugin (https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity Jump ).

Image 7Jump

If we open any sample, we find that it includes two files: Json file and Sol file.

We will use in this article this sample SimpleMarketplace

SimpleMarketplace.json defines the configuration of the blockchain application.

Image 11Jump

SimpleMarketplace.sol is written in Solidity language used in Ethereum, it allows the developer to create and update the contract and this is realised by these methods: ContractCreated() and ContractUpdated().

Image 13Jump

We have like a constructor in object-oriented language the WorkbenchBase that receives the ApplicationName and the WorkflowName as parameters.

JavaScript
function WorkbenchBase(string applicationName, string workflowName) internal {
        ApplicationName = applicationName;
        WorkflowName = workflowName;
    }

After the contracts should inherit from the base class WorkbenchBase:

JavaScript
contract SimpleMarketplace is WorkbenchBase('SimpleMarketplace', 'SimpleMarketplace')

We have Set of States that are used after in the Functions:

JavaScript
enum StateType {
      ItemAvailable,
      OfferPlaced,
      Accepted
    }
function MakeOffer(int offerPrice) public
    {
        if (offerPrice == 0)
        {
            revert();
        }
        if (State != StateType.ItemAvailable)
        {
            revert();
        }
       
        if (InstanceOwner == msg.sender)
        {
            revert();
        }
        InstanceBuyer = msg.sender;
        OfferPrice = offerPrice;
        State = StateType.OfferPlaced;
        ContractUpdated('MakeOffer');
    }

Deploy Smart Contracts

This application can be deployed in our workbench in this way:

  1. Connect as Administrator in Azure Blockchain Workbench.
  2. Select Applications > New.  The New Application pane appears.
  3. Select Upload the contract configuration after Browse to load the configuration file SimpleMarketplace.json.
  4. Select Upload the contract code after Browse to load the SimpleMarketplace.sol file.
  5. Select Deploy to create our application.
  6. Few minutes and the new application appears in Applications.

We can create more contracts from the interface:

Image 15 Jump

The same interface allows the Administrator to create more users or deploy custom contracts.

Azure Blockchain Workbench lets you integrate other services like Azure Logic, Apps, Web APIs, Notification Hubs…

Conclusion

In this article, we describe using an existent sample the way of deploying a new application in Azure Blockchain Workbench.

Azure Blockchain Workbench uses a shared view of a business process but in secure and distributed ledger and it is stand up the scaffolding around the blockchain application.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
Canada Canada
I am Rebaï Hamida, Microsoft MVP in Visual Studio and Development Technologies.
I'm a software architect and developer who like to build open source projects, writing articles, learning and teaching best practices. you can find out in my blog : http://hamidarebai.blogspot.com/

Innovative Software engineer : hands-on, competent software engineer, passionate and proficient C# developer, offering more than seven years of experience in the full software development lifecycle – from concept through delivery of next-generation applications and customized solutions, producing code to a consistently high standard and testing software across a variety of platforms.
Expert in advanced development methodologies, tools and processes contributing to the design and roll-out of cutting-edge software applications.
Known for excellent troubleshooting skills – able to analyze code and engineer well-researched, cost-effective and responsive solutions.


Success is only a consequence of a continuous work and remarkable intelligence.
I believe that I have to make a change in my country, I can’t live without leaving my footprint.

Comments and Discussions

 
-- There are no messages in this forum --