Level of Difficulty: Intermediate – Senior.
This post will assist in using Azure Blob Storage to store files used in UiPath processes.
A funny thing happened the other day… Jackson broke the news to the team that his laptop was stolen. After some panic, he lets everyone know that at least the latest solution was checked into source control (and is available on the Orchestrator). That brings some relief, until Barbra asks if the look up files are in source control too. With a worried look on his face, Jackson says, “No… Neither are any of the reference files that are referenced in the queue item.”
After much excitement, Jeremy (the boss man), mandates a central storage repository to be implemented so that this doesn’t happen in the future and so that local development isn’t relied upon. After some investigation, the team decided that Azure Storage would be a great way to go as it fits in with the general architectural direction that the company is heading in. Here’s the question though, how?
What are the steps?
The steps that we will be following are:
- Create an App Registration
- Assign the correct API permissions
- Gather the necessary info
- Application ID
- Tenant ID
- Client Secret
- Create Azure Storage Resource
- Use the created resources in UiPath
- Add Azure Scope
- Add Get Storage Account Activity
- Add Get Storage Account Key Activity
- Add Get Blob Container
- Add Upload Blob
Let’s dive deeper into the steps listed above.
Create an App Registration
Once you have logged into Azure (https://portal.azure.com/), the first thing you want to do is create an App in App Registration and you can do that by doing the following:
- Go to Azure Active Directory
- Go to App Registrations
- Click Register an application
- Provide a name and select authentication
- Hit Register
Next, you want to add the correct API permissions.
Assigning The Correct API Permissions
You will need to do the following to assign the correct API permissions:
- Inside the newly created App Registration, select API permissions
- Select Add a permission
- Add Azure Storage, user_impersonation
Now that you’ve got that set up, you want to get the Application ID, Tenant ID and Client Secret.
Gather The Necessary Info
In order to use the app that has just been registered, you’ll need to collect certain info. The info can be accessed as follows:
- Inside the newly created App Registration, select Overview
- Copy the Application (client) ID and the Directory (tenant) ID as it will be needed later
- Click on Client secrets, generate a secret
- Copy the secret and paste it somewhere for when you need it
- Click on Overview in the Azure Active Directory and copy the Tenant ID
- The Subscription ID will be visible in the Overview section of the Storage Account (once it has been created)
Now you should be ready to create your storage account.
Creating Azure Storage Resource
Hit Home in the top left hand corner and navigate to Resources.
- Hit new resource
- Search for Storage account
- Click Storage account – blob, file, table, queue
- Click Create
- Select Subscription and resource group (create one if necessary)
- Select storage account name, location, account kind (BlobStorage) and Replication (Read-access geo-redundant storage (RA-GRS))
Great! Storage account created – now to create a container within the storage account:
- Open newly created Storage Account resource
- Click on Containers
- Click Add Container
- Give it a name and access level
Storage account created, container created, but how does the App Registration tie in? Well, we still need to add it, so let’s do that.
Give the App Registration access to the Storage Account
In order to give the Registered App access to the newly created Storage Account, do the following:
- Go to the Storage Account
- Select Access Control (IAM)
- Select Add, Role Assignment
- Assign Role to Storage Blob Data Contributor
- Search for the App Registration in the Select field
- Now add another Role and assign the App Registration to the Contributor Role
Now that we have everything set up in Azure, let’s get started in UiPath.
Using Azure Storage in UiPath
In order to use the resources created on Azure, the following needs to be done:
- Create a new process and give it a name
- Add the UiPath.Azure.Activities library
- Add the Azure Scope to the sequence
- Enter the following details gathered from above:
- Add Get Storage Account Activity inside of the Azure Scope, with the following properties
- Output StorageAccount to a variable
- Add Get Storage Account Key Activity below, with the following properties
- Output StorageAccountKey to a variable
- Add Get Blob Container with the following properties
- Output BlobContainer to a variable
- Add Upload Blob from File with the following properties
- Output Blob to a variable
Now Jeremy, Jackson and the rest of the team can go about their business without worrying about stolen laptops and lost files.
If you have any questions, issues or feedback, drop a comment below or reach out to email@example.com