public virtual Uri UploadPackageToBlob(
            StorageManagementClient storageClient,
            string storageName,
            string packagePath,
            BlobRequestOptions blobRequestOptions)
        {
            StorageAccountGetKeysResponse keys = storageClient.StorageAccounts.GetKeys(storageName);
            string storageKey      = keys.PrimaryKey;
            var    storageService  = storageClient.StorageAccounts.Get(storageName);
            Uri    blobEndpointUri = storageService.Properties.Endpoints[0];

            return(UploadFile(storageName,
                              General.CreateHttpsEndpoint(blobEndpointUri.ToString()),
                              storageKey, packagePath, blobRequestOptions));
        }
        public virtual Uri UploadPackageToBlob(
            IServiceManagement channel,
            string storageName,
            string subscriptionId,
            string packagePath,
            BlobRequestOptions blobRequestOptions)
        {
            StorageService storageService = channel.GetStorageKeys(subscriptionId, storageName);
            string         storageKey     = storageService.StorageServiceKeys.Primary;

            storageService = channel.GetStorageService(subscriptionId, storageName);
            string blobEndpointUri = storageService.StorageServiceProperties.Endpoints[0];

            return(UploadFile(
                       storageName,
                       General.CreateHttpsEndpoint(blobEndpointUri), storageKey, packagePath, blobRequestOptions));
        }
예제 #3
0
        public CloudStorageAccount GetCloudStorageAccount()
        {
            if (cloudStorageAccount == null)
            {
                using (var storageClient = CreateClient <StorageManagementClient>())
                {
                    var storageServiceResponse = storageClient.StorageAccounts.Get(CurrentStorageAccountName);
                    var storageKeysResponse    = storageClient.StorageAccounts.GetKeys(CurrentStorageAccountName);

                    cloudStorageAccount = new CloudStorageAccount(
                        new StorageCredentials(storageServiceResponse.ServiceName, storageKeysResponse.PrimaryKey),
                        General.CreateHttpsEndpoint(storageServiceResponse.Properties.Endpoints[0].ToString()),
                        General.CreateHttpsEndpoint(storageServiceResponse.Properties.Endpoints[1].ToString()),
                        General.CreateHttpsEndpoint(storageServiceResponse.Properties.Endpoints[2].ToString()));
                }
            }
            return(cloudStorageAccount);
        }
        public virtual 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 = General.CreateHttpsEndpoint(
                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();
        }