Exemplo n.º 1
0
        public Task <string> GetStorageSasAsync(
            AccountSasPolicy accountPolicy, bool includeUrl = true, CancellationToken cancellationToken = default)
        {
            if (accountPolicy is null)
            {
                throw new ArgumentNullException(nameof(accountPolicy));
            }

            if (_sasSigningCredentials == null)
            {
                throw new NotSupportedException($"cannot create Shared Access Signature, you have to authenticate using Shared Key in order to issue them.");
            }

            string sas = accountPolicy.ToSasQuery(_sasSigningCredentials);

            if (includeUrl)
            {
                string url = _client.Uri.ToString();
                url += "?";
                url += sas;
                return(Task.FromResult(url));
            }

            return(Task.FromResult(sas));
        }
        public Task <string> GetStorageSasAsync(AccountSasPolicy accountPolicy, bool includeUrl)
        {
            if (accountPolicy is null)
            {
                throw new ArgumentNullException(nameof(accountPolicy));
            }

            if (_account == null)
            {
                throw new NotSupportedException($"cannot create Shared Access Signature with current connection method");
            }

            string sas = _account.GetSharedAccessSignature(accountPolicy.ToSharedAccessAccountPolicy());

            if (includeUrl)
            {
                sas = _account.BlobStorageUri.PrimaryUri + sas;
            }

            return(Task.FromResult(sas));
        }