Пример #1
0
        //ADD AILMENT DETAILS
        public void AddAilmentDetails(AilmentDetails AilData)
        {
            #if DEBUG
            account = CloudStorageAccount.DevelopmentStorageAccount;
            #else
            account = new CloudStorageAccount(accountAndKey, true);
            #endif
            client = account.CreateCloudTableClient();
            client.CreateTableIfNotExist("PatientDetails");
            tableContext = new TableServiceContext(account.TableEndpoint.ToString(), account.Credentials);

            AilmentDetails x = new AilmentDetails();
            x.AttendingPhysician = AilData.AttendingPhysician;
            x.Diagnosis = AilData.Diagnosis;
            x.DiagnosisID = AilData.DiagnosisID;
            x.GeneralPhysician = AilData.GeneralPhysician;
            x.Hospital = AilData.Hospital;
            x.Lab_Pathology = AilData.Lab_Pathology;
            x.Lab_Physical = AilData.Lab_Physical;
            x.Lab_Radiology = AilData.Lab_Physical;
            x.Medication = AilData.Medication;
            x.PatientIDLinkRowKey = AilData.PatientIDLinkRowKey;
            x.ProgressNotes = AilData.ProgressNotes;
            x.Symptoms = AilData.Symptoms;
            x.TimeIn = AilData.TimeIn;
            x.TimeOut = AilData.TimeOut;
            x.Treatment = AilData.Treatment;
            x.AilmentDetailRowKey = AilData.AilmentDetailRowKey;

            tableContext.AddObject("PatientDetails", x);
            tableContext.SaveChanges();
        }
Пример #2
0
        internal static bool InitializeStorage()
        {
            try
            {
                // 仅为测试目的,如果我们不在计算仿真程序中运行该服务,我们始终使用 dev 存储.
                if (RoleEnvironment.IsAvailable)
                {
                    CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
                    {
                        configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
                    });
                    StorageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
                }
                else
                {
                    StorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
                }

                CloudBlobClient blobClient = new CloudBlobClient(StorageAccount.BlobEndpoint, StorageAccount.Credentials);
                CloudBlobContainer container = blobClient.GetContainerReference("videostories");
                container.CreateIfNotExist();
                CloudQueueClient queueClient = new CloudQueueClient(StorageAccount.QueueEndpoint, StorageAccount.Credentials);
                CloudQueue queue = queueClient.GetQueueReference("videostories");
                queue.CreateIfNotExist();
                CloudTableClient tableClient = new CloudTableClient(StorageAccount.TableEndpoint.AbsoluteUri, StorageAccount.Credentials);
                tableClient.CreateTableIfNotExist("Stories");
                return true;
            }
            catch (Exception ex)
            {
                Trace.Write("错误初始化存储: " + ex.Message, "Error");
                return false;
            }
        }
        private void OnInitialize()
        {
            var selfInstance        = InstanceEnumerator.GetSelf();

            cloudStorageAccount     = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(ConfigurationSettingsKeys.StorageConnectionString));
            log.Info("Storage account selected: {0}",cloudStorageAccount.BlobEndpoint);
            
            cloudBlobClient         = cloudStorageAccount.CreateCloudBlobClient();
            log.Info("Storage client created");

            var containerName       = ConfigurationProvider.GetSetting(ConfigurationSettingsKeys.StorageContainerName,"ravendb");

            // In order to force a connection we just enumerate all available containers:
            var availableContainers = cloudBlobClient.ListContainers().ToArray();

            foreach (var container in availableContainers)
            {
                log.Info("Available container: {0}",container.Name);
            }

            if (!availableContainers.Any(c => c.Name.Equals(containerName)))
            {
                log.Info("Container {0} does not exist, creating",containerName);

                // Container does not exist:
                cloudBlobClient.GetContainerReference(containerName).Create();
            }

            cloudBlobContainer      = cloudBlobClient.GetContainerReference(containerName);
            log.Info("Container {0} selected",cloudBlobContainer.Name);

            localCache              = RoleEnvironment.GetLocalResource(ConfigurationSettingsKeys.StorageCacheResource);
            log.Info("Cache resource retrieved: {0}, path: {1}",localCache.Name,localCache.RootPath);
            CloudDrive.InitializeCache(localCache.RootPath, localCache.MaximumSizeInMegabytes);
            log.Info("Cache initialized: {0} mb",localCache.MaximumSizeInMegabytes);

            var driveName           = string.Format("{0}{1}.vhd", selfInstance.RoleName, selfInstance.RoleInstanceIndex).ToLowerInvariant();
            log.Info("Virtual drive name: {0}",driveName);
            
            var pageBlob            = cloudBlobContainer.GetPageBlobReference(driveName);
            log.Info("Virtual drive blob: {0}",pageBlob.Uri);

            cloudDrive              = cloudStorageAccount.CreateCloudDrive(pageBlob.Uri.ToString());
            log.Info("Virtual drive created: {0}",cloudDrive.Uri);

            var storageSize         = ConfigurationProvider.GetSetting(ConfigurationSettingsKeys.StorageSizeInMb, 50000);
            log.Info("Storage size: {0} mb",storageSize);

            cloudDrive.CreateIfNotExist(storageSize);
            log.Info("Virtual drive initialized: {0}",cloudDrive.Uri);

            var mountedDirectoryPath = cloudDrive.Mount(storageSize, DriveMountOptions.None);
            log.Info("Virtual drive mounted at: {0}",mountedDirectoryPath);

            mountedDirectory = new DirectoryInfo(mountedDirectoryPath);

            log.Info("Executing drive benchmark for: {0}",mountedDirectoryPath);
            ExecuteBenchmarks(mountedDirectory,storageSize);
            log.Info("Storage initialization succeeded");
        }
Пример #4
0
        private Stream GetTableStream(CloudStorageAccount account, string tableName, string query)
        {
            var requestUri = new StringBuilder();
            requestUri.AppendFormat("{0}{1}()", account.TableEndpoint.ToString(), tableName);
            if (String.IsNullOrWhiteSpace(query))
            {
                requestUri.AppendFormat("?{0}", query);
            }

            // create Http Request
            var request = (HttpWebRequest)HttpWebRequest.Create(requestUri.ToString());

            // For requests using the $select query option, the request must be made using version 2011-08-18
            // or newer. In addition, the DataServiceVersion and MaxDataServiceVersion headers must be set
            // to 2.0.
            // http://msdn.microsoft.com/en-us/library/dd179421.aspx
            request.Headers.Add("x-ms-version", "2011-08-18");
            request.Headers.Add("MaxDataServiceVersion", "2.0");

            // signs request using the specified credentials under the Shared Key Lite authentication
            account.Credentials.SignRequestLite(request);

            var response = (HttpWebResponse)request.GetResponse();

            // get stream from response with response encoding
            var sr = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(response.CharacterSet));

            return sr.BaseStream;
        }
		public Uri GetBlobUri(CloudStorageAccount account, string blobRelativePath)
		{
			var blobsStoragePath = account.BlobEndpoint.AbsoluteUri;
			var blobPath = blobsStoragePath.CombineUris(blobRelativePath);
			var blobUri = new Uri(blobPath);
			return blobUri;
		}
Пример #6
0
        /// <summary>
        /// Copies a blob from one account and container to another.
        /// </summary>
        /// <param name="copyBlockBlobSettings">A <see cref="CopyBlockBlobSettings"/>.</param>
        public static void CopyBlockBlob(CopyBlockBlobSettings copyBlockBlobSettings)
        {
            Contract.Requires(copyBlockBlobSettings != null, "The copy block blob settings cannot be null.");

            var sourceStorageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(copyBlockBlobSettings.BlobStorageSource, copyBlockBlobSettings.BlobStorageSourceKey), copyBlockBlobSettings.UseHttps);
            var sourceClient = sourceStorageAccount.CreateCloudBlobClient();
            var destinationStorageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(copyBlockBlobSettings.BlobStorageDestination, copyBlockBlobSettings.BlobStorageDestinationKey), copyBlockBlobSettings.UseHttps);
            var destinationClient = destinationStorageAccount.CreateCloudBlobClient();
            var destinationContainer = destinationClient.GetContainerReference(copyBlockBlobSettings.DestinationContainerName);

            try
            {
                destinationContainer.CreateIfNotExist();
            }
            catch
            {
                // do nothing, create if not exists blows up if it already exists... nice.
            }

            var sourceBlob = sourceClient.GetBlockBlobReference(copyBlockBlobSettings.BlobSourcePath);
            sourceBlob.FetchAttributes();

            CloudBlob destinationBlob = destinationClient.GetBlockBlobReference(copyBlockBlobSettings.BlobDestinationPath);

            destinationBlob.StartCopyFromBlob(sourceBlob.Uri);

            MonitorCopy(destinationBlob.Container);
        }
        public SharedAccessSignatureController(CloudStorageAccount storageAccount)
        {
            if (storageAccount == null)
                throw new ArgumentNullException("storageAccount", Constants.CloudStorageAccountNullArgumentErrorMessage);

            this.cloudBlobClient = storageAccount.CreateCloudBlobClient();
        }
Пример #8
0
        // Constructor - get settings from a hosted service configuration or .NET configuration file.
        public BlobHelper(string configurationSettingName, bool hostedService)
        {
            if (hostedService)
            {
                CloudStorageAccount.SetConfigurationSettingPublisher(
                    (configName, configSettingPublisher) =>
                    {
                        var connectionString = RoleEnvironment.GetConfigurationSettingValue(configName);
                        configSettingPublisher(connectionString);
                    }
                );
            }
            else
            {
                CloudStorageAccount.SetConfigurationSettingPublisher(
                    (configName, configSettingPublisher) =>
                    {
                        var connectionString = ConfigurationManager.ConnectionStrings[configName].ConnectionString;
                        configSettingPublisher(connectionString);
                    }
                );
            }

            Account = CloudStorageAccount.FromConfigurationSetting(configurationSettingName);

            BlobClient = Account.CreateCloudBlobClient();
            BlobClient.RetryPolicy = RetryPolicies.Retry(4, TimeSpan.Zero);
        }
 private CloudStorageAccount Patch(CloudStorageAccount account)
 {
     ServicePointManager.FindServicePoint(account.BlobEndpoint).UseNagleAlgorithm = false;
     ServicePointManager.FindServicePoint(account.TableEndpoint).UseNagleAlgorithm = false;
     ServicePointManager.FindServicePoint(account.QueueEndpoint).UseNagleAlgorithm = false;
     return account;
 }
        public WorkerRoleLoader()
        {
            this.LastModified = DateTime.MinValue;

            this.storageAccount = CloudStorageAccount.FromConfigurationSetting(DataConfigurationKey);
            this.blobStorage = storageAccount.CreateCloudBlobClient();
        }
Пример #11
0
 public AzureCommandLogReader(CloudStorageAccount account, string tableName, ITextSerializer serializer) : 
     base(account, tableName, serializer)
 {
     this.tableName = tableName;
     this.serializer = serializer;
     this.tableClient = account.CreateCloudTableClient();
 }
Пример #12
0
        public WorkerRole()
        {
            // This code sets up a handler to update CloudStorageAccount instances when their corresponding
            // configuration settings change in the service configuration file.
            CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
            {
                // Provide the configSetter with the initial value
                configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));

                RoleEnvironment.Changed += (sender, arg) =>
                {
                    if (arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
                        .Any((change) => (change.ConfigurationSettingName == configName)))
                    {
                        // The corresponding configuration setting has changed, propagate the value
                        if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)))
                        {
                            // In this case, the change to the storage account credentials in the
                            // service configuration is significant enough that the role needs to be
                            // recycled in order to use the latest settings. (for example, the 
                            // endpoint has changed)
                            RoleEnvironment.RequestRecycle();
                        }
                    }
                };
            });

            this.storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
        }
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 100;

            //Initialize Indexer
            storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("CrawlerStorage"));

            //Initialize URL Queue
            urlQueueClient = storageAccount.CreateCloudQueueClient();
            urlQueue = urlQueueClient.GetQueueReference("urlqueue");
            if (urlQueue.CreateIfNotExist())
            {
                //Add first URL to the queue
                CloudQueueMessage firstURL = new CloudQueueMessage(startURL);
                urlQueue.AddMessage(firstURL);
            }

            //Initialize Index Queue
            indexQueueClient = storageAccount.CreateCloudQueueClient();
            indexQueue = indexQueueClient.GetQueueReference("indexqueue");
            indexQueue.CreateIfNotExist();

            //Initialize Database Blob
            databaseClient = storageAccount.CreateCloudBlobClient();
            databaseContainer = databaseClient.GetContainerReference("wordfrequencies");
            databaseContainer.CreateIfNotExist();
            var permission = databaseContainer.GetPermissions();
            permission.PublicAccess = BlobContainerPublicAccessType.Container;
            databaseContainer.SetPermissions(permission);

            return base.OnStart();
        }
Пример #14
0
        public Form1()
        {
            InitializeComponent();

            // Create storage account...
            storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
        }
Пример #15
0
        static MsdnDataSource()
        {
            CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => {
                                                                         string connectionString = string.Empty;

                                                                         if (RoleEnvironment.IsAvailable) {
                                                                             connectionString = RoleEnvironment.GetConfigurationSettingValue(configName);
                                                                         }
                                                                         //else {
                                                                         //    connectionString = ConfigurationManager.AppSettings[configName];
                                                                         //}

                                                                         configSetter(connectionString);
                                                                     });

            storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

            storageAccount.CreateCloudTableClient().CreateTableIfNotExist("Namespaces");
            storageAccount.CreateCloudTableClient().CreateTableIfNotExist("Types");
            storageAccount.CreateCloudTableClient().CreateTableIfNotExist("Members");

            //CloudTableClient.CreateTablesFromModel(
            //    typeof(NamespaceMetaInfo),
            //    storageAccount.TableEndpoint.AbsoluteUri,
            //    storageAccount.Credentials);
        }
Пример #16
0
    // Constructor - pass in a storage connection string.
    public BlobHelper(string connectionString)
    {
        Account = CloudStorageAccount.Parse(connectionString);

            BlobClient = Account.CreateCloudBlobClient();
            BlobClient.RetryPolicy = RetryPolicies.Retry(4, TimeSpan.Zero);
    }
Пример #17
0
        /// <summary> Creates the storage access configuration. </summary>
        /// <param name="cloudStorageAccount">The cloud storage account.</param>
        /// <param name="storageConfigurationStorage">The config storage.</param>
        /// <returns></returns>
        public static IAzureStorageConfig CreateConfig(CloudStorageAccount cloudStorageAccount, Action<AzureStorageConfigurationBuilder> storageConfigurationStorage)
        {
            var builder = new AzureStorageConfigurationBuilder(cloudStorageAccount);
            storageConfigurationStorage(builder);

            return builder.Build();
        }
Пример #18
0
        public EventStore(CloudStorageAccount account, string tableName)
        {
            if (account == null) throw new ArgumentNullException("account");
            if (tableName == null) throw new ArgumentNullException("tableName");
            if (string.IsNullOrWhiteSpace(tableName)) throw new ArgumentException("tableName");

            this.account = account;
            this.tableName = tableName;
            this.tableClient = account.CreateCloudTableClient();
            this.tableClient.RetryPolicy = RetryPolicies.NoRetry();

            // TODO: This could be injected.
            var backgroundRetryStrategy = new ExponentialBackoff(10, TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(1));
            var blockingRetryStrategy = new Incremental(3, TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1));
            this.pendingEventsQueueRetryPolicy = new RetryPolicy<StorageTransientErrorDetectionStrategy>(backgroundRetryStrategy);
            this.pendingEventsQueueRetryPolicy.Retrying += (s, e) =>
            {
                var handler = this.Retrying;
                if (handler != null)
                {
                    handler(this, EventArgs.Empty);
                }

                Trace.TraceWarning("An error occurred in attempt number {1} to access table storage (PendingEventsQueue): {0}", e.LastException.Message, e.CurrentRetryCount);
            };
            this.eventStoreRetryPolicy = new RetryPolicy<StorageTransientErrorDetectionStrategy>(blockingRetryStrategy);
            this.eventStoreRetryPolicy.Retrying += (s, e) => Trace.TraceWarning(
                "An error occurred in attempt number {1} to access table storage (EventStore): {0}",
                e.LastException.Message,
                e.CurrentRetryCount);

            this.eventStoreRetryPolicy.ExecuteAction(() => tableClient.CreateTableIfNotExist(tableName));
        }
Пример #19
0
        //This function is using storage client ddl of blob
        public byte[] DownloadBlobClient(string UserId, string BlobName)
        {
            // Retrieve storage account from connection string.
            Microsoft.WindowsAzure.CloudStorageAccount StorageAccount = Microsoft.WindowsAzure.CloudStorageAccount.Parse(Convert.ToString(ConfigurationManager.AppSettings["StorageConnectionString"]));

            // Create the blob client.
            Microsoft.WindowsAzure.StorageClient.CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient();

            // Retrieve a reference to a container.
            Microsoft.WindowsAzure.StorageClient.CloudBlobContainer container = blobClient.GetContainerReference(UserId);

            // Create the container if it doesn't exist.
            container.CreateIfNotExist();


            //Set permission to public
            container.SetPermissions(
                new Microsoft.WindowsAzure.StorageClient.BlobContainerPermissions
            {
                PublicAccess =
                    Microsoft.WindowsAzure.StorageClient.BlobContainerPublicAccessType.Off
            });


            // Retrieve reference to a blob named

            Microsoft.WindowsAzure.StorageClient.CloudBlockBlob blockBlob = container.GetBlockBlobReference(BlobName);


            return(blockBlob.DownloadByteArray());
        }
Пример #20
0
        public UserDataSource(CloudStorageAccount storageAccount)
        {
            _storageAccount = storageAccount;
            _cloudTableClient = storageAccount.CreateCloudTableClient();

            _cloudTableClient.CreateTableIfNotExist("Users");
        }
Пример #21
0
 static AzureStorageServiceBase()
 {
     if (RoleEnvironment.IsEmulated)
         storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
     else
         storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(StorageConnectionString));
 }
Пример #22
0
		public void Install(IPaths paths, CloudStorageAccount storageAccount, int port, ICloudDriveManager cloudDriveManager)
		{
			Trace.TraceInformation("Installing Neo4j server.");

			DownloadJava(paths, storageAccount);
            UnzipJava(paths);

			DownloadNeo4j(paths, storageAccount);
			UnzipNeo4j(paths);

            try
            {
                // try to mount cloud drive
                MountDatabase(paths, cloudDriveManager);
                SetServerDbPathConfig(paths, port);
            }
            catch (Exception ex)
            {
                Trace.TraceError("Drive Mounting Error: " + ex.Message);
            }
            
			SetServerPortAndUrlConfig(paths, port);
			SetJavaPath(paths);
			CopyConfigurationFilesToLogsDirectory(paths);

			ClearLogDirectory(paths);

			Trace.TraceInformation("Neo4j server installed.");
		}
 public FriendshipRepository()
 {
     storage = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
     client = storage.CreateCloudTableClient();
     client.CreateTableIfNotExist(TableName);
     context = client.GetDataServiceContext();
 }
Пример #24
0
        public PhotoAlbumDataContext(Microsoft.WindowsAzure.CloudStorageAccount account)
            : base(account.TableEndpoint.ToString(), account.Credentials)
        {
            if (!initialized)
            {
                lock (initializationLock)
                {
                    if (!initialized)
                    {
                        this.CreateTables();
                        initialized = true;
                    }
                }
            }

            // we are setting up a dictionary of types to resolve in order
            // to workaround a performance bug during serialization
            this.resolverTypes = new Dictionary <string, Type>();
            this.resolverTypes.Add(AlbumTable, typeof(AlbumRow));
            this.resolverTypes.Add(PhotoTable, typeof(PhotoRow));
            this.resolverTypes.Add(TagTable, typeof(TagRow));
            this.resolverTypes.Add(PhotoTagTable, typeof(PhotoTagRow));

            this.ResolveType = (name) =>
            {
                var parts = name.Split('.');
                if (parts.Length == 2)
                {
                    return(resolverTypes[parts[1]]);
                }

                return(null);
            };
        }
Пример #25
0
        public AzureStorageProvider(CloudStorageAccount storageAccount)
        {
            cloudStorageAccount = storageAccount;

            // Create the blob client
            blobStorage = cloudStorageAccount.CreateCloudBlobClient();
        }
 public PushServiceTokenRepository()
 {
     storage = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
     client = storage.CreateCloudTableClient();
     client.CreateTableIfNotExist(TableName);
     context = new TableServiceContextV2(client.BaseUri.ToString(), client.Credentials);
 }
Пример #27
0
        public AzureEventStore(CloudStorageAccount storageAccount)
        {
            _account = storageAccount;
            _tableClient = _account.CreateCloudTableClient();

            InitializeStorage();
        }
 public PushServiceTokenRepository()
 {
     storage = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
     client = storage.CreateCloudTableClient();
     client.CreateTableIfNotExist(TableName);
     context = new TableServiceContextV2(client.BaseUri.ToString(), client.Credentials);
 }
        public static void InitializeCloudStorage(CloudStorageAccount account)
        {
            CloudTableClient cloudTableClient = account.CreateCloudTableClient();
            CloudQueueClient cloudQueueClient = account.CreateCloudQueueClient();

            CreateUserPrivilegeTable(cloudTableClient);
        }
Пример #30
0
        public Storage(CloudStorageAccount account)
        {
            this.account = account;

            fileStorage = account.CreateCloudBlobClient();

            /* Initialize file container */
            container = fileStorage.GetContainerReference(filesContainer);
            container.CreateIfNotExist();

            var permissions = container.GetPermissions();
            /* Full permissions. From MSDN, Container-level public access. Anonymous clients can
             * read blob content and metadata and container metadata, and can list the blobs within the container.
             *
             * Other alternatives are Blob (can read content but not metadata) and Off (no
             * anonymous access).
             */
            // permissions.PublicAccess = BlobContainerPublicAccessType.Container;
            permissions.PublicAccess = BlobContainerPublicAccessType.Off;

            permissions.SharedAccessPolicies.Remove("basic");
            permissions.SharedAccessPolicies.Add("basic", new SharedAccessPolicy()
            {
            });

            container.SetPermissions(permissions);

            /* Initialize table (for file metadata) */
            CloudTableClient.CreateTablesFromModel(
                typeof(FileDataContext),
                account.TableEndpoint.AbsoluteUri,
                account.Credentials);
        }
 public PushServiceTokenRepository()
 {
     storage = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
     client = storage.CreateCloudTableClient();
     client.CreateTableIfNotExist(TableName);
     context = client.GetDataServiceContext();
 }
 public given_blob_storage()
 {
     var settings = InfrastructureSettings.Read("Settings.xml").BlobStorage;
     this.account = CloudStorageAccount.Parse(settings.ConnectionString);
     this.rootContainerName = Guid.NewGuid().ToString();
     this.sut = new CloudBlobStorage(account, this.rootContainerName);
 }
        public virtual CloudStorageAccount GetAccount()
        {
            var cred = new Microsoft.WindowsAzure.StorageCredentialsAccountAndKey("cloud302blobby",
                                                                                  "PDyi8E91Txm+NqS7yUByQkQ933Tfp6/tbgvVG0Z4zvrIrgnG0P5J3bf9hMm7EZ9Ll6R2ol70UjjHU3rI9EO8uA==");
            var account = new Microsoft.WindowsAzure.CloudStorageAccount(cred, true);

            return(account);
        }
Пример #34
0
        public static void ProcessFile(string file)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["StorageConnection"].ToString();

            Microsoft.WindowsAzure.Storage.CloudStorageAccount account = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(connectionString);
            StorageCredentialsAccountAndKey cre = new StorageCredentialsAccountAndKey(account.Credentials.AccountName, account.Credentials.ExportBase64EncodedKey());

            Microsoft.WindowsAzure.CloudStorageAccount ac = new Microsoft.WindowsAzure.CloudStorageAccount(cre, true);
            CloudTableClient client = account.CreateCloudTableClient();
            CloudTable       table  = client.GetTableReference("employe");

            table.CreateIfNotExists();
            var dt = DataAccess.DataTable.New.ReadAzureBlob(ac, "fileupload", file);

            foreach (var row in dt.Rows)
            {
                EmployeeTableEntity emp = new EmployeeTableEntity {
                    EmployeeId = Convert.ToInt16(row["EmployeeId"]), FirstName = row["FirstName"], LastName = row["LastName"], ContactNo = row["ContactNo"], EmailId = row["EmailId"], PartitionKey = row["EmployeeId"], RowKey = Guid.NewGuid().ToString()
                };
                TableOperation operation = TableOperation.InsertOrMerge(emp);
                table.Execute(operation);
            }
        }
Пример #35
0
        private void initDisk()
        {
            LocalResource localCache = RoleEnvironment.GetLocalResource("InstanceDriveCache");

            Microsoft.WindowsAzure.StorageClient.CloudDrive.InitializeCache(localCache.RootPath, localCache.MaximumSizeInMegabytes);

            CloudBlobContainer driveContainer = renderStorage.Get().CreateContainer(BlobName.DRIVES_BLOB, false);
            CloudPageBlob      pageBlob       = driveContainer.GetPageBlobReference("renderVHD" + RoleEnvironment.CurrentRoleInstance.Id + ".vhd");

            Microsoft.WindowsAzure.CloudStorageAccount      StorageClientStorageAccount = Microsoft.WindowsAzure.CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
            Microsoft.WindowsAzure.StorageClient.CloudDrive drive = Microsoft.WindowsAzure.StorageClient.CloudStorageAccountCloudDriveExtensions.CreateCloudDrive(StorageClientStorageAccount, pageBlob.Uri.ToString());

            try
            {
                drive.CreateIfNotExist(localCache.MaximumSizeInMegabytes);
                drive.Mount(0, Microsoft.WindowsAzure.StorageClient.DriveMountOptions.None);
                System.IO.Directory.SetCurrentDirectory(drive.LocalPath);
                m_localDirectory = drive.LocalPath;
            }
            catch (Microsoft.WindowsAzure.StorageClient.CloudDriveException ex)
            {
                m_log.Error("Create disk error: " + ex.Message);
            }
        }