当前位置: 首页>>代码示例>>C#>>正文


C# StorageCredentials类代码示例

本文整理汇总了C#中StorageCredentials的典型用法代码示例。如果您正苦于以下问题:C# StorageCredentials类的具体用法?C# StorageCredentials怎么用?C# StorageCredentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StorageCredentials类属于命名空间,在下文中一共展示了StorageCredentials类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SensorAccess

 public SensorAccess()
 {
     credentials = new StorageCredentials(_accountName, _key);
     storageAccount = new CloudStorageAccount(credentials, true);
     tableClient = storageAccount.CreateCloudTableClient();
     table = tableClient.GetTableReference("AccelerometerTable");
 }
开发者ID:shijiong,项目名称:FallDetection,代码行数:7,代码来源:StorageSensor.cs

示例2: CloudQueueClient

        /// <summary>Initializes a new instance of the <see cref="CloudQueueClient"/> class.</summary>
        /// <param name="usePathStyleUris">True to use path style Uris. </param>
        /// <param name="baseAddressUri">The base address Uri. </param>
        /// <param name="credentials">The credentials. </param>
        internal CloudQueueClient(bool? usePathStyleUris, Uri baseAddressUri, StorageCredentials credentials)
        {
            CommonUtils.AssertNotNull("baseAddress", baseAddressUri);
            CommonUtils.AssertNotNull("credentials", credentials);

            if (!credentials.CanSignRequest)
            {
                throw new ArgumentException(SR.CredentialsCantSignRequest, "credentials");
            }

            this.BaseUri = baseAddressUri;

            if (!this.BaseUri.IsAbsoluteUri)
            {
                CommonUtils.ArgumentOutOfRange("baseAddress", baseAddressUri);
            }

            this.Timeout = Constants.DefaultClientSideTimeout;
            this.RetryPolicy = RetryPolicies.RetryExponential(
                RetryPolicies.DefaultClientRetryCount, RetryPolicies.DefaultClientBackoff);
            this.Credentials = credentials;

            // if use path style uris doesn't have a value, automatically decide whether to use host style uri or path style uri
            this.UsePathStyleUris = usePathStyleUris.HasValue ? usePathStyleUris.Value : CommonUtils.UsePathStyleAddressing(this.BaseUri);
        }
开发者ID:wforney,项目名称:azure-sdk-for-net,代码行数:29,代码来源:CloudQueueClient.cs

示例3: TableServiceContext

        /// <summary>Initializes a new instance of the <see cref="TableServiceContext"/> class.</summary>
        /// <param name="baseAddress">The Table service endpoint to use create the service context. </param>
        /// <param name="credentials">The account credentials. </param>
        public TableServiceContext(string baseAddress, StorageCredentials credentials)
            : base(new Uri(baseAddress))
        {
            if (string.IsNullOrEmpty(baseAddress))
            {
                throw new ArgumentNullException("baseAddress");
            }

            if (credentials == null)
            {
                throw new ArgumentNullException("credentials");
            }

            if ((!credentials.CanSignRequest) || (!credentials.CanSignRequestLite))
            {
                throw new ArgumentException(SR.CredentialsCantSignRequest, "credentials");
            }

            this.SendingRequest += this.DataContextSendingRequest;

            this.StorageCredentials = credentials;
            this.IgnoreMissingProperties = true;
            this.MergeOption = MergeOption.PreserveChanges;

            this.RetryPolicy = RetryPolicies.RetryExponential(
                RetryPolicies.DefaultClientRetryCount, RetryPolicies.DefaultClientBackoff);
            this.Timeout = (int)TimeSpan.FromSeconds(90).TotalSeconds;
        }
开发者ID:wforney,项目名称:azure-sdk-for-net,代码行数:31,代码来源:TableServiceContext.cs

示例4: TableStorageAppender

 public TableStorageAppender(StorageCredentials credentials)
 {
     if (credentials.AccountName.StartsWith("devstoreaccount"))
         StorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
     else
         StorageAccount = new CloudStorageAccount(credentials, true);
     TableName = "WADLogsTable";
     TransferIntervalInMinutes = 5;
     LogmarkerIntervalInMinutes = 30;
 }
开发者ID:rajeshgupthar,项目名称:Ms.Azure.Logging,代码行数:10,代码来源:TableStorageAppender.cs

示例5: DeletePackageFromBlob

 public static void DeletePackageFromBlob(IServiceManagement channel, string storageName, string subscriptionId, Uri packageUri)
 {
     var storageService = channel.GetStorageKeys(subscriptionId, storageName);
     var storageKey = storageService.StorageServiceKeys.Primary;
     storageService = channel.GetStorageService(subscriptionId, storageName);
     var blobStorageEndpoint = new Uri(storageService.StorageServiceProperties.Endpoints.Find(p => p.Contains(BlobEndpointIdentifier)));
     var credentials = new StorageCredentials(storageName, storageKey);
     var client = new CloudBlobClient(blobStorageEndpoint, credentials);
     ICloudBlob blob = client.GetBlobReferenceFromServer(packageUri);
     blob.DeleteIfExists();
 }
开发者ID:OctopusDeploy,项目名称:azure-sdk-tools,代码行数:11,代码来源:AzureBlob.cs

示例6: RemoveVHD

        public static void RemoveVHD(IServiceManagement channel, string subscriptionId, Uri mediaLink)
        {
            var accountName = mediaLink.Host.Split('.')[0];
            var blobEndpoint = new Uri(mediaLink.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped));

            StorageService storageService;
            using (new OperationContextScope(channel.ToContextChannel()))
            {
                storageService = channel.GetStorageKeys(subscriptionId, accountName);
            }

            var storageAccountCredentials = new StorageCredentials(accountName, storageService.StorageServiceKeys.Primary);
            var client = new CloudBlobClient(blobEndpoint, storageAccountCredentials);
            var blob = client.GetBlobReferenceFromServer(mediaLink);
            blob.DeleteIfExists();
        }
开发者ID:Viachaslau,项目名称:azure-sdk-tools,代码行数:16,代码来源:Disks.cs

示例7: CloudQueue

        /// <summary>
        /// Initializes a new instance of the <see cref="CloudQueue"/> class.
        /// </summary>
        /// <param name="usePathStyleUris">True to use path style Uris.</param>
        /// <param name="address">The address.</param>
        /// <param name="credentials">The credentials.</param>
        internal CloudQueue(bool? usePathStyleUris, string address, StorageCredentials credentials)
        {
            CommonUtils.AssertNotNullOrEmpty("address", address);
            CommonUtils.AssertNotNull("credentials", credentials);

            if (!credentials.CanSignRequest)
            {
                throw new ArgumentException(SR.CredentialsCantSignRequest, "credentials");
            }

            this.EncodeMessage = true;
            this.attributes = new QueueAttributes() { Uri = new Uri(address) };

            string baseAddress = NavigationHelper.GetServiceClientBaseAddress(this.Uri, usePathStyleUris);

            this.ServiceClient = new CloudQueueClient(baseAddress, credentials);
            this.Name = NavigationHelper.GetQueueNameFromUri(this.Uri, this.ServiceClient.UsePathStyleUris);
        }
开发者ID:nickchal,项目名称:pash,代码行数:24,代码来源:CloudQueue.cs

示例8: GetStorageCredentials

        /// <summary>
        /// Attempts to get the user's credentials from the given Storage Context or the current subscription, if the former is null. 
        /// Throws a terminating error if the credentials cannot be determined.
        /// </summary>
        public static StorageCredentials GetStorageCredentials(this ServiceManagementBaseCmdlet cmdlet, AzureStorageContext storageContext)
        {
            StorageCredentials credentials = null;

            if (storageContext != null)
            {
                credentials = storageContext.StorageAccount.Credentials;
            }
            else
            {
                var storageAccountName = cmdlet.CurrentSubscription.CurrentStorageAccountName;
                
                if (!string.IsNullOrEmpty(storageAccountName))
                {
                    var keys = cmdlet.StorageClient.StorageAccounts.GetKeys(storageAccountName);
                    
                    if (keys != null)
                    {
                        var storageAccountKey = string.IsNullOrEmpty(keys.PrimaryKey) ? keys.SecondaryKey : keys.PrimaryKey;

                        credentials = new StorageCredentials(storageAccountName, storageAccountKey);
                    }
                }
            }

            if (credentials == null)
            {
                cmdlet.ThrowTerminatingError(
                    new ErrorRecord(
                        new UnauthorizedAccessException(Resources.AzureVMDscDefaultStorageCredentialsNotFound),
                        string.Empty,
                        ErrorCategory.PermissionDenied,
                        null));
            }

            if (string.IsNullOrEmpty(credentials.AccountName))
            {
                cmdlet.ThrowInvalidArgumentError(Resources.AzureVMDscStorageContextMustIncludeAccountName);
            }

            return credentials;
        }
开发者ID:kangyangthu,项目名称:azure-sdk-tools,代码行数:46,代码来源:ServiceManagementBaseCmdletExtentions.cs

示例9: Storage

        public Storage()
        {
            var accountName = WebConfigurationManager.AppSettings["AccountName"];
            var accountKey = WebConfigurationManager.AppSettings["AccountKey"];
            bool useHttps = WebConfigurationManager.AppSettings["DefaultEndpointsProtocol"].ToLower() == "https";

            StorageCredentials credentials = new StorageCredentials(accountName, accountKey);
            CloudStorageAccount storageAccount = new CloudStorageAccount(credentials, useHttps);

            // Create the blob client.
            var blobClient = storageAccount.CreateCloudBlobClient();

            // Retrieve a reference to a container.
            Messages = blobClient.GetContainerReference("messages");
            Users = blobClient.GetContainerReference("users");

            // Create the container if it doesn't already exist.
            Messages.CreateIfNotExists();

            Users.CreateIfNotExists();
        }
开发者ID:nikkios,项目名称:SignalRChat,代码行数:21,代码来源:Storage.cs

示例10: RetrieveTable

        internal List<ProductEntity> RetrieveTable()
        {
            StorageCredentials creds = new StorageCredentials(accountName, accountKey);
            CloudStorageAccount account = new CloudStorageAccount(creds, useHttps: true);
            CloudTableClient tableClient = account.CreateCloudTableClient();

            // Retrieve storage account from the connection string
               // CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
             //   ConfigurationManager.ConnectionStrings["BlobStorageConnectionString"].ConnectionString);

            // Create the table client
            //CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            // Create the CloudTable object that represents the "product" table
            CloudTable table = tableClient.GetTableReference("products");

            // Construct the query operation for all product entities
            TableQuery<ProductEntity> query = new TableQuery<ProductEntity>();

            var products = table.ExecuteQuery(query).ToList();

            return products;
        }
开发者ID:Slettan,项目名称:ProductsAPI,代码行数:23,代码来源:ProductRepository.cs

示例11: GetSasUrlStr

        protected string GetSasUrlStr(string storageName, string storageKey, string containerName, string blobName)
        {
            var cred = new StorageCredentials(storageName, storageKey);
            var storageAccount = string.IsNullOrEmpty(this.StorageEndpointSuffix)
                               ? new CloudStorageAccount(cred, true)
                               : new CloudStorageAccount(cred, this.StorageEndpointSuffix, true);

            var blobClient = storageAccount.CreateCloudBlobClient();
            var container = blobClient.GetContainerReference(containerName);
            var cloudBlob = container.GetBlockBlobReference(blobName);
            var sasToken = cloudBlob.GetSharedAccessSignature(
                new SharedAccessBlobPolicy()
                {
                    SharedAccessExpiryTime = DateTime.UtcNow.AddHours(24.0),
                    Permissions = SharedAccessBlobPermissions.Read
                });

            // Try not to use a Uri object in order to keep the following 
            // special characters in the SAS signature section:
            //     '+'   ->   '%2B'
            //     '/'   ->   '%2F'
            //     '='   ->   '%3D'
            return cloudBlob.Uri + sasToken;
        }
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:24,代码来源:SetAzureVMCustomScriptExtension.cs

示例12: CloudPageBlob

 /// <summary>
 /// Initializes a new instance of the <see cref="CloudPageBlob"/> class using an absolute URI to the blob.
 /// </summary>
 /// <param name="blobAddress">The absolute URI to the blob.</param>
 /// <param name="credentials">The account credentials.</param>
 public CloudPageBlob(string blobAddress, StorageCredentials credentials)
     : base(blobAddress, credentials)
 {
     this.Properties.BlobType = BlobType.PageBlob;
 }
开发者ID:aliakb,项目名称:azure-sdk-for-net,代码行数:10,代码来源:CloudPageBlob.cs

示例13: InitializeAzureTableLogging

 /// <summary>
 /// Initializes log4net with azure table logging.
 /// </summary>
 public static void InitializeAzureTableLogging(StorageCredentials credentials, string customTable = null, Level logLevel = null)
 {
     if (credentials.AccountName.StartsWith("devstoreaccount"))
         InitializeAzureTableLogging(CloudStorageAccount.DevelopmentStorageAccount, customTable, logLevel);
     else
         InitializeAzureTableLogging(new CloudStorageAccount(credentials, true), customTable, logLevel);
 }
开发者ID:rajeshgupthar,项目名称:Ms.Azure.Logging,代码行数:10,代码来源:LoggingHelper.cs

示例14: CloudBlob

 /// <summary>
 /// Initializes a new instance of the <see cref="CloudBlob"/> class using an absolute URI to the blob, and the snapshot timestamp,
 /// if the blob is a snapshot.
 /// </summary>
 /// <param name="blobAbsoluteUri">The absolute URI to the blob.</param>
 /// <param name="snapshotTime">The snapshot timestamp, if the blob is a snapshot.</param>
 /// <param name="credentials">The account credentials.</param>
 public CloudBlob(string blobAbsoluteUri, DateTime? snapshotTime, StorageCredentials credentials)
     : this(blobAbsoluteUri, snapshotTime, new CloudBlobClient(NavigationHelper.GetServiceClientBaseAddress(blobAbsoluteUri, null), credentials))
 {
 }
开发者ID:rmarinho,项目名称:azure-sdk-for-net,代码行数:11,代码来源:CloudBlob.cs

示例15: SetupCommands

        private void SetupCommands()
        {
            Add_Patient = new DelegateCommand(async () =>
               {
                   Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Wait, 2);
           
                   MessageDialog mm = new MessageDialog("mission Started");
                   //await mm.ShowAsync();

                   // Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Wait, 2);

                   if (string.IsNullOrWhiteSpace(Pa.FName) ||
                      string.IsNullOrWhiteSpace(Pa.LName) ||
                      string.IsNullOrWhiteSpace(Pa.Gender) ||
                      string.IsNullOrWhiteSpace(Pa.MaritalStatus) ||
                      string.IsNullOrWhiteSpace(Pa.SocialID) ||
                      string.IsNullOrWhiteSpace(Pa.Email) ||
                      string.IsNullOrWhiteSpace(Pa.Phone))
                   {
                       //show message
                       mm = new MessageDialog("Please fill in all the fields");
                       await mm.ShowAsync();
                       return;
                   }

                  // Pa.Dob = Convert.ToDateTime(String.Format("{0:d}", Pa.Dob));
                   switch (Pa.Gender)
                   {
                       case "0":
                           Pa.Gender = "Male";
                           break;

                       case "1":
                           Pa.Gender = "Female";
                           break;
                   }

                   switch (Pa.MaritalStatus)
                   {
                       case "0":
                           Pa.MaritalStatus = "Single";
                           break;

                       case "1":
                           Pa.MaritalStatus = "Married";
                           break;
                   }

                   /////////////////////////////////////////////////////////////// save the image
                   string errorString = string.Empty;

                   if (media != null)
                   {
                       // Set blob properties of TodoItem.
                       Pa.ContainerName = "patientimagestorageimages";
                       Pa.ResourceName = media.Name;
                   }
                   else
                   {
                       if( Pa.Gender == "Male"){

                           var uri = new Uri("ms-appx:///Assets/Administrator-icon.png");

                           media = await StorageFile.GetFileFromApplicationUriAsync(uri);

                           Pa.ContainerName = "patientimagestorageimages";
                           Pa.ResourceName = media.Name;
                       }
                       else
                       {
                           var uri = new Uri("ms-appx:///Assets/Office-Girl-icon.png");

                           media = await StorageFile.GetFileFromApplicationUriAsync(uri);

                           Pa.ContainerName = "patientimagestorageimages";
                           Pa.ResourceName = media.Name;
                       }
                   }
                  



                   /////////////////////////////////////////////////////////////////
                   try
                   {
                       await patientsTable.InsertAsync(Pa);
                   }
                   catch (Exception e)
                   {
                       mm = new MessageDialog("error occured");
                       mm.ShowAsync();
                   }

                   //if (media != null)
                   //{
                   if (!string.IsNullOrEmpty(Pa.SasQueryString))
                   {
                       using (var fileStream = await media.OpenStreamForReadAsync())
                       {
                           StorageCredentials cred = new StorageCredentials(Pa.SasQueryString);
//.........这里部分代码省略.........
开发者ID:Zainabalhaidary,项目名称:Clinic,代码行数:101,代码来源:PatientViewModel.cs


注:本文中的StorageCredentials类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。