cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

AzureBlobStorage.CreateShareLinkByPath parameters for Shared Access Signature

I'm getting stuck working with AzureBlobStorage to store MS Office documents and then launch them in the appropriate application. The problem is setting up the Shared Access Signature.

 

Say I've successfully uploaded a Word document "MyDoc.docx" into /attachments. I've got as far as this action to open the document in Word:

 

Launch(
  "ms-word:ofe|u|" & AzureBlobStorage.CreateShareLinkByPath(
    "/attachments/MyDoc.docx"
  ).WebUrl
)

Word launches fine but I get the error "We can't connect to https://myblobsxxx. Please make sure you're using the correct web address".

 

I can get round this by going into Azure Storage Explorer and setting the Public Access level to "Public read access for container and blobs", so it's clearly a permissions issue. But I want to control access to my Blob Container rather than leave it open.

 

I've tried this:

Launch(
  "ms-word:ofe|u|" & AzureBlobStorage.CreateShareLinkByPath(
    "/attachments/MyDoc.docx",
    {
      ExpiryTime: DateValue("1/1/2050"),
      Permissions: "Read"
    }
  ).WebUrl
)

but it still fails to open. I can't find anywhere that explains the possible settings for the CreateShareLinkByPath parameters - the documentation doesn't give samples.

 

I know there is another option of appending a Shared Access Signature that's been generated in Azure Storage Explorer to the url - is that the way? Hard code a SAS from Storage Explorer that has an infinite expiry date? Doesn't seem right.. Or can I generate one of those within PowerApps somehow?

 

Help appreciated!

 

 

2 REPLIES 2
Highlighted
Super User
Super User

Re: AzureBlobStorage.CreateShareLinkByPath parameters for Shared Access Signature

I think you need to break it down into steps.

1. Save the File to Blob Storage

2. Set the permissions and get back the Web URL

3. Store Web URL

4. Open the document using the Web URL.

 

I suspect in your set up, that perhaps the Web URL is not being returned before the Launch is firing.

I *think* each time you run CreateShareLinkByPath you will be overwriting any existing shared access link. Probably better to create one link (when you save the document) store the link and re-use it as required (that is the pattern I use and have not had issues).

Highlighted
Advocate II
Advocate II

Re: AzureBlobStorage.CreateShareLinkByPath parameters for Shared Access Signature

Thanks @PaulD1 

Yes, that makes sense to generate the WebURL at the time of saving.

When I tried this I still got the error, but then found more information about the MSWord launch URI schema here. This states "These schemes do not include an authority component as defined in section 3.2 of RFC 3986. Invocation of the commands specified in this document takes place in the context of the system invoking the command".

If I just launch the WebURL, without the prefix "ms-word:ofe|u|", it launches a browser which in turn downloads the docx file, and this download can be opened as normal.

It looks like the reason I can't cut out the browser-launch and go straight to launching MSWord is not because of a problem with CreateShareLinkByPath, but because ms-word:ofe|u| doesn't work in this particular case, where the authority to open is expressed in the suffix of the URL (?sv=2018-03-28&sr=b..etc).

Shame - you either have to set your Blob Container Access Level to Public, in which case the direct launch of MSWord (or any other Office application) works fine using the appropriate URI prefix; or you have to make the user launch a browser instead and download the document into their Downloads folder, and then double-click to launch Word.

Not a showstopper, just feels a bit clunky!

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,072)