-
Notifications
You must be signed in to change notification settings - Fork 62
PowerApps Connecting from GCC to any Endpoint including Commercial Azure
pierowman edited this page Jun 29, 2021
·
3 revisions
- In Power Apps create a custom connector using Azure Rest API, in this case blob storage
- Create a Power Automate create a Flow that will convert the response from the Custom Connector into a format that can be displayed in Power Apps Canvas App
- From Power Apps Canvas App, call the Flow to display the response from the Rest API
- When doing this, careful thought should be put into security
- Azure Blob Storage - creating a SAS token and setting the appropriate permissions for the use case. Creating Blob SAS token
- Power Apps for custom connectors by default are limited to the creator but can be expanded. Sharing Custom Connectors
- Power Automate Flows can be given permissions as well, typically permissions should be set to match permissions set on the Power App. Sharing Power Automate Flows
- Create a SAS token
- Get the SAS URI should look like:
https://myaccount.blob.core.windows.net/?restype=service&comp=properties&sv=2019-02-02&ss=bf&srt=s&st=2019-08-01T22%3A18%3A26Z&se=2019-08-10T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=JBoQmAOAz7qROPEawv%2Bh0bn9ZIWe747N8NnhGQQPNxU%3D
- When entering the SAS URI into Custom Connector it UTF-8 encodes it. Yet the SAS URI is already UTF-8 encoded. So to work properly the
<some value>
part ofsig=<some value>
needs to be un-encoded, in this caseJBoQmAOAz7qROPEawv%2Bh0bn9ZIWe747N8NnhGQQPNxU%3D
- Use UTF-8 Decoder to decode the values that are
% + number + letter
pattern. - Continuing with the same example the values to un-encode are
%2B
and%3D
which become+
and=
- Resulting in
JBoQmAOAz7qROPEawv+h0bn9ZIWe747N8NnhGQQPNxU=
this is what needs to be entered into the connector. - When testing the connector you can validate that the SAS token is encoded back to the expected format. Note there maybe some values that do not need to be converted.
- In the custom connector you want to make sure that the Azure Blob Storage URI is in the format documented for Azure Blob Storage Rest API.
Tip: You can use Postman to validate you have the calls right before entering them into Custom Connector.
- Here is an example for Get List Blobs:
https://myaccount.blob.core.windows.net/containername?restype=container&comp=list&sp=racwdl&st=2021-05-13T17:38:06Z&se=2022-06-02T01:38:06Z&spr=https&sv=2020-02-10&sr=c&sig=JBoQmAOAz7qROPEawv%2Bh0bn9ZIWe747N8NnhGQQPNxU%3D
- Create a new Flow
- Create a PowerApps trigger
- Add the custom connector from above, search by the connectors name
- Add a 'Compose' task
- name it 'Response Body - XML to JSON'
- click on 'Inputs'
- select 'Expression'
- enter
json(xml(outputs('GetBlobList').body))
- Save the Flow and Run the Flow. In the run results go to the 'Response Body - XML to JSON' and copy the Raw Output of the 'Outputs'
- Add 'Parse Json' task
- In Content select 'Outputs' from 'Response Body - XML to JSON'
- For the Schema click 'Generate from sample' paste in the Raw Output.
- Add 'Initialize Variable' task
- Give it a name
- Select 'Array' for the Type
- Add 'Apply to each' task
- In the 'Select an output from previous steps' click and select expression
- Enter
body('Parse_JSON')?['EnumerationResults']?['Blobs']?['Blob']
- Click 'Add an Action' in the 'Apply to each' task
- Choose 'Append to array variable' task
- In the Name select the variable created in the previous step
- In the Value select Name from the Dynamic content from 'Parse Json'
- Add a 'Response' task
- In the Body select the variable
- In the 'Response Body JSON Schema'
{
"type": "array",
"items": {
"type": "string"
}
}
- In a Canvas App create a Button
- Configure the button to call the Flow
- OnSelect fx= ClearCollect(MyResults, MyFlow.Run())
- Create an empty Gallery
- Set the Gallery Data Source to the collection MyResults used on the button.
- Add a text Label to the Gallery
- Add a Label 'baseUrlLabel' and set its text to be the first half of the download blob url
https://myaccount.blob.core.windows.net/containername/
- Add a Label 'queryStringLabel' and set its text to be the last half of the blob url
?sp=racwdl&st=2021-05-13T17:38:06Z&se=2022-06-02T01:38:06Z&spr=https&sv=2020-02-10&sr=c&sig=JBoQmAOAz7qROPEawv%2Bh0bn9ZIWe747N8NnhGQQPNxU%3D
- Edit the Gallery Label's 'OnSelect' to be
Launch(baseUrlLabel.Text & ThisItem.Value & queryStringLabel.Text)
- You can change the properties of the Gallery Textbox to show as underlined and the text as blue to show as a hyperlink