コード例 #1
0
        /// <summary>
        /// Create and Get Json Blob
        /// </summary>
        /// <returns></returns>
        public static async Task CreateAndGetJsonBlob()
        {
            CloudStorageAccount storageAccount = GetCloudStorageAccount.CreateStorageAccount();
            string TestContainerName           = containerName + DateTime.Now.ToString("yyyyMMddhhmmss").ToString();

            blobStorage = new BlobStorage(storageAccount, TestContainerName, BlobContainerPublicAccessType.Blob);

            List <CustomerEntity> insertEntityList = InsertDataCount.CreateCustomerEntity();

            string serializeListEntity = JsonConvert.SerializeObject(insertEntityList);

            string currentBlobName = BlobName + DateTime.Now.ToString("yyyyMMddhhmmss").ToString();
            await blobStorage.CreateBlockBlobString(currentBlobName, "application/json", serializeListEntity);

            string getJsonObject = await blobStorage.GetBlockBlobDataString(currentBlobName);

            List <CustomerEntity> getListEntity = JsonConvert.DeserializeObject <List <CustomerEntity> >(getJsonObject).ToList();

            if (getListEntity.Count == insertEntityList.Count &&
                insertEntityList.Count == GetSameEntities(getListEntity, insertEntityList).Count())
            {
                Log.Info("Get blob Data success, Count:{0}", getListEntity.Count);
                //blobStorage.DeleteContainer();
            }
            else
            {
                Log.Error("Get blob Data Fail, Expect Count:{0}, Actual Count{1}, blob Container name:{2}",
                          insertEntityList.Count, getListEntity.Count, TestContainerName);
            }
        }