locked
Get page ranges using SDK results in 403 after using SAS URI. RRS feed

  • Question

  • I am trying to reconstruct blobs using incremental snapshots S1,S2 using the SDK for Java. The destination storage account A1 operates on the blobs.

    The flow looks like the following:

    1. Incremental snapshots are scanned.

    2. Destination blob is created on the first snapshot S1.

    3. Get page range diff is constructed between S2 and S1.

    4. Put page range is used on the results obtained from step 3.

    I have trouble in setting up the step 3 as it results in com.microsoft.azure.storage.StorageException: This request is not authorized to perform this operation.

    The sample code for step 3 looks like the following:

      

    	final Snapshot first = snapshots.get(0);
    			final Snapshot second = snapshots.get(1);
    			try
    			{
    				final URI firstUri = new URI(first.grantAccess(ACCESS_TIMEOUT_SECS));
    				final URI secondUri = new URI(second.grantAccess(ACCESS_TIMEOUT_SECS));
    				final CloudPageBlob firstBlob = new CloudPageBlob(firstUri);
    				final CloudPageBlob secondBlob = new CloudPageBlob(secondUri);
    				final String firstSnapshotID = firstBlob.getSnapshotID();
    				final String secondSnapshotID = secondBlob.getSnapshotID();
    				logger.info("{}", firstUri);
    				logger.info("{}", secondUri);
    				logger.info("{}", firstSnapshotID);
    				logger.info("{}", secondSnapshotID);
    				final List<PageRangeDiff> downloadPageRangesDiff = secondBlob.downloadPageRangesDiff(firstSnapshotID);
    				logger.info("success");
    			}
    			catch (StorageException | URISyntaxException e)
    			{
    				logger.error("Error caught", e);
    			}
    			finally
    			{
    				first.revokeAccess();
    				second.revokeAccess();
    			}

    I have tried generating the SAS uri for the second blob alone and it still doesn't work. Is there a way to get around this?

    I am able to download the blob to local storage but not able to get the page range diffs between the two.


    • Edited by dmachop Wednesday, October 30, 2019 7:26 PM more info
    Wednesday, October 30, 2019 7:15 PM

All replies

  • @dmachop Just for clarification: Have you set any policy, if so check the expiry time and also verify your date and time?  Can you please share the screen shot of the error message? 
    Based on the error code 403 is typically caused by authentication failure. Please ensure SAS has enough permission.  
    Thursday, October 31, 2019 10:49 AM
  • @SumanthMarigowda-MSFT

    Sure! Policy access looks good. The time is also correct. Moreover, I'm able to get a response using the Rest API

    The URL looks like

    https://<snapshot2_sas_uri>/abcd?snapshot=<snapshot2_time>&sv=<sv_val>&sr=bs&si=<si_val>&sig=<sig_val>&comp=pagelist
    with headers:
    xm-ms-version: 2019-04-04
    x-ms-previous-snapshot-url: <snapshot1_sas_uri>


    However, the data from the SDK using logging generates the request:

    https://<snapshot2_sas_uri>/abcd?sig=<sig_val>&comp=pagelist&api-version=2019-02-02&sv=<sv_val>&si=<si_val>&prevsnapshot=<snapshot1_time>&snapshot=<snapshot2_time>&sr=bs


    The obvious issue on SDK is that sas_uri for snapshot1 and snapshot2 vary. Rest has the capability of mentioning the custom header on sas_uri for snapshot1 as well as avoiding the prevsnapshot param which would make this work. Is there a way on the SDK method to do this?



    • Edited by dmachop Thursday, October 31, 2019 3:37 PM formatting
    Thursday, October 31, 2019 3:37 PM