Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?

Technical dive for Implementing Blockchain for Shipment Management in SharePoint

Embark on a journey the place innovation meets real-world software! This submit delves into the realm of integrating blockchain into SharePoint, demystifying its simplicity via a sensible case. Image a world firm specializing in NBA shirt gross sales, our point of interest in the present day, grappling with the intricacies of shipments and deliveries. This situation serves as a tangible instance to unravel the function of blockchain in SharePoint amidst on a regular basis enterprise challenges.

This marks the second half, exploring the intricate technical points of the answer. In the meantime, the preliminary phase, titled Implementing Blockchain for Shipment and Delivery Management in SharePoint, affords a complete view of the enterprise aspect and resolution. We hope you discover each segments enlightening!

This exploration is not only for tech lovers; it is an invite to witness the magic of technological simplification.

The article is split into three elements, breaking down the info layer, the API layer, and the implementation of the enterprise layer in Azure Logic Apps. Acquire a complete view with the accompanying technical diagram.



Knowledge layer

The app information resides in SharePoint On-line, requiring three lists: shipments, deliveries, and an occasion log capturing creation, modification, and deletion occasions for each. Basically, this final listing features as our blockchain storage.

The Cargo Data listing handles cargo administration, that includes customized columns alongside customary SharePoint On-line columns:

  • Cargo ID information the cargo identifier.
  • Cargo Date designates the cargo’s scheduled date.
  • Cargo Data captures further particulars in regards to the cargo.

 raw `Shipment Information` endraw  list

The Supply Particulars listing manages supply content material and contains customized columns alongside customary SharePoint On-line columns:

  • Supply ID information the supply identifier.
  • Supply Date designates the scheduled supply date.
  • Cargo ID information the related cargo identifier, linking to the corresponding cargo document.
  • Recipient Data captures further particulars in regards to the supply.

 raw `Delivery Details` endraw  list

Lastly, the listing that would be the retailer of our blockchain known as Occasion Monitoring Data and, aside from the usual SharePoint columns, it has the next customized columns distributed in 2 sorts of content material:

  • For the Cargo Block Occasion content material sort:
    • Cargo ID,
    • Cargo Date,
    • Cargo Creator,
    • Report Creation,
    • Block Hash
  • For the Supply Block Occasion content material sort:
    • Supply ID,
    • Supply Date,
    • Cargo ID,
    • Supply Creator,
    • Report Creation,
    • Block Hash

Lastly, the listing designated as our blockchain repository is called Occasion Monitoring Data. Along with customary SharePoint columns, it contains the next customized columns distributed throughout two content material sorts.

For the Cargo Block Occasion content material sort: Cargo ID, Cargo Date, Cargo Creator, Report Creation, and Block Hash.

For the Supply Block Occasion content material sort: Supply ID, Supply Date, Cargo ID, Supply Creator, Report Creation, and Block Hash.

 raw `Event Tracking Information` endraw  list settings



API Layer

The API layer implementation on this train is simple. It consists of a single operate developed in Azure Features utilizing Node.js because the engine for executing performance.

Beneath, you will discover the supply code for the operate, permitting you to watch its simplicity regardless of being full of validations and log messages.

const crypto = require("crypto");
const { app } = require('@azure/features');

const secret = 'YOUR SECRET HERE';


operate getSourceParameterNotFoundBodyAnswer() {
    return {
        jsonBody: {
            message: 'supply parameter have to be offered'
        },
        standing: 400
    };
}


app.http('generateHashFromText', {
    strategies: ['post'],
    route: 'hash/textual content',
    authLevel: 'nameless',
    handler: async (request, context) => {
        attempt {
            context.log(`Http operate processed request for url "${request.url}"`);
            
            context.hint(`Acquiring physique parameters...`);
            
            // Checking if there's something within the physique content material...
            if(request.physique === undefined || request.physique === null) {
                context.warn(`No physique parameters have been offered.`);
                return getSourceParameterNotFoundBodyAnswer();
            }

            // Checking if there's something within the physique out of being empty...
            const bodyContent = await request.physique.getReader().learn();
            if(bodyContent.worth.size === 0) {
                context.warn(`No physique parameters have been offered.`);
                return getSourceParameterNotFoundBodyAnswer();
            }

            // Studying supply parameter from the physique
            const physique = JSON.parse(new TextDecoder().decode(bodyContent.worth));
            const supply = physique.supply;

            if(supply === undefined || supply === null || supply === '') {
                context.data(`supply question parameter not discovered.`);
                return getSourceParameterNotFoundBodyAnswer();
            }

            context.data(`supply question parameter worth: ${supply}`);

            // Doing the hash to the supply parameter content material...
            context.hint(`Do the hash for supply worth...`);
            const hasher = crypto.createHmac("sha256", secret);
            const outcome = hasher.replace(supply).digest('hex');

            context.hint(`Hash obtained is ${outcome}`);

            // Returning the hash....
            return {
                jsonBody: {
                    hash: outcome,
                    supply: supply,
                },
                standing: 200
            };
        }
        catch(err) {
            context.error(`An unknow error has ocurred: ${err}`);
            return {
                jsonBody: {
                    err: err
                },
                standing: 500
            };
        }
    }
});
Enter fullscreen mode

Exit fullscreen mode



Azure Logic Apps and Customized Connector



Customized connector configuration

The setup of the Customized Connector is simple. After implementing the API, including the related data is all that is required. If you happen to’re acquainted with OpenAPI or Swagger, this course of is intuitive. For these unfamiliar, Microsoft’s information, Create a custom connector from scratch, gives step-by-step directions. Take note of the settings within the third step, which change into seen when you choose it as an motion throughout the deployment of Azure Logic Apps.

Step 3 of the Custom Connector configuration



When a brand new Cargo is created in Azure Logic Apps

I might wish to stroll you thru the implementation particulars of a selected Azure Logic App—particularly, the one triggered after a brand new merchandise is submitted. The remainder of the Azure Logic Apps work in an identical means however with the corresponding set off for modification and deletion.

The implementation unfolds in six phases, every with a definite and detailed goal.

Azure Logic Apps On Shipment Creation Event



1. The set off

The set off is about as much as establish any newly created merchandise within the Cargo listing inside SharePoint On-line. It is a easy course of the place we merely specify the SharePoint On-line website and select the related listing.

Phase 1 - SharePoint Online Trigger



2. Variable initialization

I wish to underscore the importance of building these two stream variables. Initially, to protect the hash of our blockchain’s newest block, we initialize a variable named LatestBlockHash. Provided that hashes are alphanumeric, we set its sort to string. The default worth is about to 0, serving because the hash for the genesis block or the chain’s first block in case no blocks exist but.

Conversely, we additionally initialize the ShipmentBlockHash variable, additionally of sort string, to retailer the hash of the upcoming block. This variable guides us all through the method and gives a traceable document of the worth generated at every stage if wanted.

Phase 2 - Variable set up



3. Get the newest block hash

At this stage, we navigate to our repository housing the blockchain to fetch the newest block and consequently, get hold of the worth of the property the place its hash is saved. Our blockchain resides in a SharePoint On-line listing, and that is the place we retrieve the newest block.

As illustrated within the picture, we make the most of the motion to fetch gadgets from the SharePoint On-line listing. We specify the location and listing, and for enhanced efficiency, we prepare the gadgets based mostly on the creation date column, ordered from latest to oldest. Moreover, we decide to retrieve just one merchandise, streamlining the method for the system to effectively return the specified merchandise.

Following this, we assign the worth of the Block Hash column to the LatestBlockHash variable, initialized earlier, enabling its incorporation into the brand new block.

Phase 3 - Obtaining the latest block hash



4. Generate the cargo block

This step is simple; we solely want to offer the required data to our Customized Connector. As talked about earlier, Azure Logic Apps lacks an motion to generate a hash worth. Therefore, we have created an API to meet this want and configured an Azure Logic Apps Customized Connector for its utilization.

The textual content string we transmit to generate a brand new block contains the properties of the created Cargo and the hash worth of the final block within the blockchain. The configuration of the supply parameter within the Customized Connector is printed under:

concat('Cargo#;#',triggerBody()?['Shipment_x0020_ID'],'#;#',triggerBody()?['Shipment_x0020_Date'],'#;#',triggerBody()?['Author']?['Email'],'#;#',triggerBody()?['Created'],'#;#',variables('LatestBlockHash'))
Enter fullscreen mode

Exit fullscreen mode

Commencing with the textual content string ‘Cargo’ for block sort identification, the next parameters include the ID area, cargo date, SharePoint merchandise creator, merchandise creation date, and in the end, the hash of the final blockchain block. The string ‘#;#’ features as a separator for these values.

Following that, we assign the generated hash worth to the ShipmentBlockHash variable.

Phase 4 - Generation of the new hash



5. Add block occasion to the blockchain listing

By using the operate to append a brand new merchandise to a SharePoint On-line listing, we retailer our just lately created block, capturing the transaction, such because the initiation of a brand new cargo on this occasion.

The setup is simple; we begin by designating the SharePoint On-line website and the listing related to the occasion log. Subsequently, we enter the suitable values into the corresponding fields. Notably, the Block Hash area is of explicit significance, because it receives the freshly generated hash from the previous stage, saved within the ShipmentBlockHash variable.

Phase 5 - Adding the new block to the blockchain



6. Notification

The ultimate stage is discretionary. In my situation, I opted to dispatch an e mail to the administrator each time a block is generated, serving as a notification for the finished exercise. Alternatively, this step may be substituted with some other type of notification or annotation inside one other system, or it may be omitted from the workflow totally.

Phase 6 - Notification



Conclusion

I belief that participating on this train has sparked inspiration for varied concepts as you mirror on its content material. The underlying goal is to discover various applied sciences, perceive their potential, and achieve hands-on expertise. Via this course of, my purpose is to share these insights with you, not solely as a document of experimentation but in addition as a supply of encouragement on your personal ventures and explorations within the realm of expertise and innovation.

By delving into this train, we open doorways to new prospects and discoveries. It is a testomony to the spirit of experimentation, demonstrating the potential of mixing totally different applied sciences. As we navigate via these technical intricacies, the last word purpose just isn’t solely to showcase what’s achievable but in addition to encourage a group of lovers, encouraging them to embark on their distinctive journeys of exploration and technological experimentation.



References

Add a Comment

Your email address will not be published. Required fields are marked *

Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?