Instant Estimate +44(0)1908738254
YOUR EXPERT RPA PARTNER

Team up with our RPA strategy and tech specialists for maximum automation impact

Find out more
Harness the power of UiPath in your business.
WATCH NOW

Save money and spend more time on priority work.

Book consultation
READY, SET, AUTOMATE

Let's choose, design and deploy a process automation solution for your business.

Find out more
TRANSFORM YOUR BUSINESS

Let's analyse your business to discover opportunities for innovation and automation.

Find out more

Begin your business transformation journey

Book consultation
AUTOMATE EVERY FUNCTION

Automate where it matters most. Scale to solve challenges in every area

Find out more
GIVE EVERY TEAM THE TOOLS FOR SUCCESS

Equip people with user-friendly solutions that save time and make work easier

Find out more

Which business problem
can we solve first?

Book consultation
27 June 2016

Connect to SQL Azure using a custom K2 Service Broker

SQL azure k2

When you want to communicate with a SQL Azure database using K2, it can easily be achieved by following the steps below once you have an SQL Azure database in place –

  1. Create a Class Library Project in Visual Studio
  • Navigate to File.
  • Navigate to New
  • Click New Project
  • Search for the Class Library Project

K2 Automated Testing Software

BenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.

 

Free K2 Five Upgrade Review

1 K2 for Visual Studio - New Class Library

  • Name the project and click OK

Your Class library project should be created now and the Project should look like this.

K2 for Visual Studio - New Class Library Code

Delete the Class named “Class1”

  1. Create the ServiceBroker Class to register the project in K2
  • Create a New Class with the name “ServiceBroker”
  • Add the “K2ServiceBroker” from nuget
  • inherit from the : ServiceAssemblyBase
  • Override the GetConfigSection Method
  • Add the 2 Configs you need to communicate with the Azure Database

K2 Service Broker

The 2 config sections below are the necessary information required to connect to the Azure Server.

  • End Point
  • Azure Connection String

The steps that we followed up to this point were to create and register a K2 Service Broker.

  1. Create the class that does the Actual Work
  • Create The class named “AzureBlobService”
  • Add the Attributes ServiceObject To the AzureBlobService (this is just the name and description of the service in the TesterTool of k2 that would be displayed)
  • Add an Empty Constructor into the AzureBlobService and the Following Properties :

K2 Service Broker - Service Config

  • And then we add 3 More Properties. These properties is just an Example

K2 Service Broker - Properties

The Attribute Above the properties specifies the Actual Property for K2. Now that we added the Properties, we can continue to the Actual Method to call from K2.

  1. Create a Method Named “Create”

K2 Service Broker - Methods

K2 sees the Create method like this:

Create(FileDate ,FileName,FilePath)

Instead of just passing the variables into the method, K2 sets the Properties and you can use the properties.

Now before you can do any work on the Azure database, you have to connect to the database.

  1. Connecting to the Azure Database inside the Create Method:
  • Add the Reference “WindowsAzure.Storage” from Nuget
  • Add the Following Code to Connect to the Azure Database

sql azure k2

  • Now the first section gets the Connection String from the Configuration Section
  • The second section created the actual connection as a client to azure to communicate with the database
  • Then it gets the reference Container
  • And if it doesn’t exists, it is created the container.

You method should now look like this –

K2 Service Broker - Full Create Method

Now you just register the dll as a K2 Service Broker, the communication to the Azure database is done and the implementation of the method is up to the reader.

Need further technical advice or support?