0
votes

I have this method that upload files to blob storage 5-10 min before it is just working fine. suddendly it started to throw error :-

private async Task UploadFileToBlobStorage()
    {
        var filename = "AppId_2.zip";
        var blobContainer = GetBlobClient.GetContainerReference("testwpclientiapcontainer");
        await blobContainer.CreateIfNotExistsAsync(); // Error is coming at this line

        var blob = blobContainer.GetBlockBlobReference(filename);

        using (var filestream = Application.GetResourceStream(new Uri(filename, UriKind.Relative)).Stream)
        {
            await blob.UploadFromStreamAsync(filestream);
        }
    }

I have check my account and key and tried for other storage account too.

Error :-

Message : The remote server returned an error: Forbidden.

Source : Microsoft.WindowsAzure.Storage

does anybody know anything about it ?

1
Could you check if there's any issue with the clock on the machine where your code is running? Get the UTC time on that machine and compare it with UTC time from a site like this: worldtimeserver.com/current_time_in_UTC.aspx. - Gaurav Mantri
@GauravMantri actually my Windows phone emulator time is mismatched.Thanks a lot man :) - loop
Yeah. You will get this Forbidden (403) error in two situations: 1) When you use incorrect account key and 2) When the time on the machine where you run the code is not in sync with time in Azure. If the time is off by 5 - 10 minutes, things will still work but more than 15 minutes or so, you will start getting this error. - Gaurav Mantri
You can add this as an answer :) - loop

1 Answers

4
votes

Please check the clock on the machine (or virtual machine) where your code is running.

You will get this Forbidden (403) error in two situations:

  1. When you use incorrect account key (which is not the case for you as you were able to upload files).

  2. When the time on the machine where you run the code is not in sync with time in Azure. If the time is off by 5 - 10 minutes, things will still work but more than 15 minutes or so, you will start getting this error.