{"id":4068,"date":"2023-11-04T23:14:02","date_gmt":"2023-11-04T23:14:02","guid":{"rendered":"http:\/\/localhost:10003\/using-azure-blockchain-workbench-for-development-and-management-of-blockchain-applications\/"},"modified":"2023-11-05T05:48:22","modified_gmt":"2023-11-05T05:48:22","slug":"using-azure-blockchain-workbench-for-development-and-management-of-blockchain-applications","status":"publish","type":"post","link":"http:\/\/localhost:10003\/using-azure-blockchain-workbench-for-development-and-management-of-blockchain-applications\/","title":{"rendered":"Using Azure Blockchain Workbench for development and management of blockchain applications"},"content":{"rendered":"
Blockchain technology has grown considerably over the last few years, with various use cases emerging across different industries. However, the development and management of blockchain-based applications can be challenging, especially for developers who lack expertise in decentralized ledger technologies. This is where Azure Blockchain Workbench comes in. This platform can help developers build, deploy, and manage blockchain applications with ease.<\/p>\n
In this tutorial, we will cover the basics of Azure Blockchain Workbench and provide step-by-step instructions on how to create and deploy a simple blockchain application.<\/p>\n
Before we dive into the tutorial, you need to have some basic knowledge of blockchain technology and a Microsoft Azure account. Additionally, you should ensure that you have access to the following:<\/p>\n
To begin, you need to set up Azure Blockchain Workbench in your Azure account. Follow these steps:<\/p>\n
+ Create a resource<\/code>.<\/li>\n- Search for
Blockchain Workbench<\/code> in the search bar.<\/li>\n- Select
Blockchain Workbench<\/code>.<\/li>\n- Follow the instructions to set up Blockchain Workbench.<\/li>\n<\/ol>\n
Once you have set up Blockchain Workbench on Azure, you need to set up your local development environment by installing the Azure Blockchain Workbench extension for Visual Studio Code.<\/p>\n
To install this extension, open Visual Studio Code and navigate to the Extensions view. Search for Azure Blockchain Workbench<\/code>, then select Install<\/code>.<\/p>\nStep 2: Creating a Blockchain Application on Azure Blockchain Workbench<\/h2>\n
Once you have your development environment set up, you can create your first blockchain application. We will create a simple application to demonstrate the process.<\/p>\n
Step 2.1: Creating an Azure Blockchain Workbench Project<\/h3>\n
To create a new project in Azure Blockchain Workbench, follow these steps:<\/p>\n
\n- Open Visual Studio Code and click on
File > New Project<\/code>.<\/li>\n- Select
Azure Blockchain Workbench Project<\/code>.<\/li>\n- Name your project and choose where to save it.<\/li>\n
- Select
Create<\/code>.<\/li>\n<\/ol>\nStep 2.2: Creating a JSON Definition File<\/h3>\n
The next step is to create a JSON definition file that defines your blockchain application’s functionality. Here is an example of what a simple JSON definition file might look like:<\/p>\n
{\n \"$schema\": \"https:\/\/blockchainworkbench.azure.com\/schemas\/definition-2021-03-01.json#\",\n \"name\": \"MyFirstBlockchainApplication\",\n \"description\": \"A simple blockchain application\",\n \"version\": \"1.0.0\",\n \"author\": \"Your Name\",\n \"packageName\": \"com.example.myfirstblockchainapplication\",\n \"connectionProfiles\": [\n {\n \"name\": \"myconnection\",\n \"description\": \"My connection profile\",\n \"key\": \"**********\",\n \"type\": \"FABRIC\"\n }\n ],\n \"applicationProfiles\": [\n {\n \"name\": \"myApplication\",\n \"description\": \"My application profile\",\n \"state\n\ns\": [\n {\n \"name\": \"active\",\n \"description\": \"The active state\",\n \"visible\": true,\n \"initial\": true,\n \"transitions\": [\n {\n \"name\": \"deactivate\",\n \"description\": \"Transition to the deactivated state\",\n \"to\": \"deactivated\",\n \"conditions\": []\n }\n ]\n },\n {\n \"name\": \"deactivated\",\n \"description\": \"The deactivated state\",\n \"visible\": true,\n \"initial\": false,\n \"transitions\": [\n {\n \"name\": \"activate\",\n \"description\": \"Transition to the activated state\",\n \"to\": \"active\",\n \"conditions\": []\n }\n ]\n }\n ]\n }\n ],\n \"assets\": [\n {\n \"name\": \"MyAsset\",\n \"description\": \"An asset \n\nin my blockchain application\",\n \"visibility\": \"public\",\n \"state\": \"active\",\n \"tags\": [],\n \"applicationProfileName\": \"myApplication\"\n }\n ]\n}\n<\/code><\/pre>\nThe JSON definition file contains information such as the application name, author, and version, as well as connection profiles, application profiles, and assets.<\/p>\n
Step 2.3: Compiling the Project<\/h3>\n
Now that you have created your JSON definition file, you are ready to compile your project. To do this, follow these steps:<\/p>\n
\n- Open Visual Studio Code and go to the
Azure Blockchain Workbench Explorer<\/code>.<\/li>\n- Right-click on your project and select
Compile Smart Contracts<\/code>. <\/li>\n<\/ol>\nYou should see a console output that shows the progress of your project’s compilation. If everything is successful, you should see a message indicating that the project has been compiled successfully.<\/p>\n
Step 2.4: Deploying the Project<\/h3>\n
After compiling your project, the next step is to deploy it to Azure Blockchain Workbench. Here’s how:<\/p>\n
\n- Go to the
Azure Blockchain Workbench Explorer<\/code> in Visual Studio Code.<\/li>\n- Right-click on your project and select
Deploy to Blockchain Workbench<\/code>.<\/li>\n- Wait for the process to complete.<\/li>\n<\/ol>\n
Once your project is successfully deployed, you should be able to see it in Azure Blockchain Workbench’s Applications<\/code> tab.<\/p>\nStep 2.5: Testing the Application<\/h3>\n
To test your application, follow these steps:<\/p>\n
\n- Go to your project folder in Visual Studio Code and open the
test<\/code> folder.<\/li>\n- Open
test.js<\/code> and replace the sample code with the following:\nconst dotenv = require('dotenv');\nconst axios = require('axios');\nconst { Client, Identity } = require('@textile\/threads-client');\n\nconst record = { \n patientName: \"Alice\",\n age: 30,\n weight: 65.2\n};\n\n(async function () {\n dotenv.config();\n\n try {\n\n console.log(`Creating Identity...`);\n const identity = await Identity.fromRandom();\n\n console.log(`Creating Client...`);\n const client = await Client.withKeyInfo({\n key: process.env.KEY,\n secret: process.env.SECRET\n });\n\n console.log(`Creating Database...`);\n const db = await client.newDB();\n\n console.log(`Database Created with ID: ${db.dbID}`);\n console.log(`Database Information: `, db);\n\n console.log(`Inserting Record...`);\n const insert = await db.create(identity, record);\n\n let result = await db.has(insert);\n if(result) {\n console.log(`Record Inserted Successfully with ID: ${insert}`);\n } else {\n console.log(`Record Insert Failed`);\n }\n\n console.log(`Fetching Record...`);\n const filter = { patientName: 'Alice' }\n const query = await db.find(filter);\n\n if(query.length > 0) {\n console.log(`Record Fetched Successfully: `, query[0]);\n } else {\n console.log(`Record Fetch Failed`);\n }\n\n } catch (err) {\n console.log(`Error Occured: ${err.message}`);\n }\n})();\n<\/code><\/pre>\n<\/li>\n- Save the file and close it.<\/p>\n<\/li>\n
- \n
Go to the console and run the following command to install the necessary packages:<\/p>\n
npm install dotenv axios @textile\/threads-client\n<\/code><\/pre>\n<\/li>\n- Run the following command to execute the test file:\n
node test.js\n<\/code><\/pre>\n<\/li>\n<\/ol>\nIf everything runs successfully, you should see output in the console that indicates that the record was successfully created and retrieved.<\/p>\n
That’s it – you have created and deployed your first blockchain application!<\/p>\n
Conclusion<\/h2>\n
In this tutorial, we covered the basics of Azure Blockchain Workbench and provided step-by-step instructions on how to create and test a simple blockchain application. By following these steps, you should now have an understanding of how to use Azure Blockchain Workbench to develop and manage blockchain applications.<\/p>\n","protected":false},"excerpt":{"rendered":"
Introduction Blockchain technology has grown considerably over the last few years, with various use cases emerging across different industries. However, the development and management of blockchain-based applications can be challenging, especially for developers who lack expertise in decentralized ledger technologies. This is where Azure Blockchain Workbench comes in. This platform Continue Reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[1141,411,1138,1139,1140,1142,1145,1143,1144,1137],"yoast_head":"\nUsing Azure Blockchain Workbench for development and management of blockchain applications - Pantherax Blogs<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n