CreateHttpsEndpoint() public static method

Creates https endpoint from the given endpoint.
public static CreateHttpsEndpoint ( string endpointUri ) : Uri
endpointUri string The endpoint uri.
return System.Uri
コード例 #1
0
        public Uri UploadFileToBlob(BlobUploadParameters parameters)
        {
            StorageAccountGetKeysResponse keys = StorageManagementClient.StorageAccounts.GetKeys(parameters.StorageName);
            string storageKey = keys.PrimaryKey;
            StorageAccountGetResponse storageService = StorageManagementClient.StorageAccounts.Get(parameters.StorageName);
            Uri blobEndpointUri = storageService.StorageAccount.Properties.Endpoints[0];

            return(UploadFile(parameters.StorageName,
                              StorageUtilities.CreateHttpsEndpoint(blobEndpointUri.ToString()),
                              storageKey, parameters));
        }
コード例 #2
0
        /// <summary>
        /// Create a cloud storage account using a service management storage client
        /// </summary>
        /// <param name="storageClient">The client to use to get storage account details.</param>
        /// <param name="accountName">The name of the storage account.</param>
        /// <returns>A CloudStorageAccount that can be used by windows azure storage library to manipulate objects in the storage account.</returns>
        public static CloudStorageAccount GenerateCloudStorageAccount(IStorageManagementClient storageClient, string accountName)
        {
            if (!TestMockSupport.RunningMocked)
            {
                var storageServiceResponse = storageClient.StorageAccounts.Get(accountName);

                Uri fileEndpoint  = null;
                Uri blobEndpoint  = null;
                Uri queueEndpoint = null;
                Uri tableEndpoint = null;

                if (storageServiceResponse.StorageAccount.Properties.Endpoints.Count >= 4)
                {
                    fileEndpoint =
                        StorageUtilities.CreateHttpsEndpoint(
                            storageServiceResponse.StorageAccount.Properties.Endpoints[3].ToString());
                }

                if (storageServiceResponse.StorageAccount.Properties.Endpoints.Count >= 3)
                {
                    tableEndpoint =
                        StorageUtilities.CreateHttpsEndpoint(
                            storageServiceResponse.StorageAccount.Properties.Endpoints[2].ToString());
                    queueEndpoint =
                        StorageUtilities.CreateHttpsEndpoint(
                            storageServiceResponse.StorageAccount.Properties.Endpoints[1].ToString());
                }

                if (storageServiceResponse.StorageAccount.Properties.Endpoints.Count >= 1)
                {
                    blobEndpoint =
                        StorageUtilities.CreateHttpsEndpoint(
                            storageServiceResponse.StorageAccount.Properties.Endpoints[0].ToString());
                }

                return(new CloudStorageAccount(
                           GenerateStorageCredentials(storageClient, storageServiceResponse.StorageAccount.Name),
                           blobEndpoint,
                           queueEndpoint,
                           tableEndpoint,
                           fileEndpoint));
            }
            else
            {
                return(new CloudStorageAccount(
                           new StorageCredentials(accountName,
                                                  Convert.ToBase64String(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()))),
                           new Uri(string.Format("https://{0}.blob.core.windows.net", accountName)),
                           new Uri(string.Format("https://{0}.queue.core.windows.net", accountName)),
                           new Uri(string.Format("https://{0}.table.core.windows.net", accountName)),
                           new Uri(string.Format("https://{0}.file.core.windows.net", accountName))));
            }
        }