Beispiel #1
0
        public void GetSasToken()
        {
            var sasuri = TokenGenerator.GetBlobSasUri(Container, "messageType/queue/2015-06-20/filename_21-58-40_fc5ebd3b-ca42-41fb-abec-842db13ccd4b.xml");

            CloudBlockBlob cloudBlockBlob = new CloudBlockBlob(new Uri(sasuri));

            string text = cloudBlockBlob.DownloadText();
        }
        public void TestBlobAttributesEncryption()
        {
            this.blob.FetchAttributes();
            Assert.IsTrue(this.blob.Properties.IsServerEncrypted);

            CloudBlockBlob testBlob = this.container.GetBlockBlobReference(this.blob.Name);

            testBlob.DownloadText();
            Assert.IsTrue(testBlob.Properties.IsServerEncrypted);
        }
        static void Main(string[] args)
        {
            var blobName = args[0];
            var blobUri = new Uri(blobName);
            var numTopN = int.Parse(args[1]);

            var blob = new CloudBlockBlob(blobUri);
            var content = blob.DownloadText();
            var words = content.Split(' ');
            var topNWords = words.Where(word => word.Length > 0)
                .GroupBy(word => word, (key, group) => new KeyValuePair<string, long>(key, group.LongCount()))
                .OrderByDescending(x => x.Value)
                .Take(numTopN)
                .ToList();

            foreach (var pair in topNWords)
            {
                Console.WriteLine("{0} {1}", pair.Key, pair.Value);
            }
        }
        private void DownloadResults(string key, AzureBlobDataReference blobLocation)
        {
            if (_outputDestination != DestinationType.None)
            {
                var credentials = new StorageCredentials(blobLocation.SasBlobToken);
                var cloudBlob = new CloudBlockBlob(new Uri(new Uri(blobLocation.BaseLocation), blobLocation.RelativeLocation), credentials);

                if (_outputDestination == DestinationType.FileConnection)
                {
                    ConnectionManager connectionManager = _connections[_destination];
                    var connection = (object)null;

                    try
                    {
                        connection = connectionManager.AcquireConnection(null);

                        string filePath = connection.ToString();

                        cloudBlob.DownloadToFile(filePath, FileMode.Create);
                    }
                    finally
                    {
                        if (connection != null && connectionManager != null)
                            connectionManager.ReleaseConnection(null);
                    }
                }
                else if (_outputDestination == DestinationType.Variable)
                {
                    var variables = (Variables)null;
                    _variableDispenser.LockOneForWrite(_destination, ref variables);

                    try
                    {
                        var variable = variables[_destination];

                        if (variable != null)
                        {
                            variable.Value = cloudBlob.DownloadText();
                        }
                    }
                    finally
                    {
                        if (variables != null)
                            variables.Unlock();
                    }
                }

                _componentEvents.FireInformation(0, "ExecuteAzureMLBatch",
                    string.Format("The result '{0}' is available: BaseLocation: '{1}' RelativeLocation: '{2}' SasBlobToken: '{3}'",
                        key,
                        blobLocation.BaseLocation,
                        blobLocation.RelativeLocation,
                        blobLocation.SasBlobToken),
                    null, 0, ref fireAgain);
            }
        }
 static string GetBlobData(CloudBlockBlob cloudBlockBlob)
 {
     return cloudBlockBlob.DownloadText(TextEncoding, new AccessCondition(),
         new BlobRequestOptions { RetryPolicy = new ExponentialRetry() }, new OperationContext());
 }