public class Album : TableServiceEntity
{
}
public class PhotoAlbumDataContext : TableServiceContext
{
public PhotoAlbumDataContext()
: this(CloudStorageAccount.FromConfigurationSetting("DataConnectionString"))
{
} public PhotoAlbumDataContext(Microsoft.WindowsAzure.CloudStorageAccount account)
: base(account.TableEndpoint.ToString(), account.Credentials)
{
if (!initialized)
{
lock (initializationLock)
{
if (!initialized)
{
this.CreateTables();
initialized = true;
}
}
} }
//getlist
var context = new PhotoAlbumDataContext();
var list=context.Albums.AsTableServiceQuery().AsEnumerable() //add
context.AddObject("Alblum_TableName", new Album());
//context.SaveChanges();
context.SaveChanges(SaveChangesOptions.ContinueOnError); //get delete
var album = context.Albums
.Where(a => a.AlbumId == albumName && a.PartitionKey == owner.ToLowerInvariant()).AsTableServiceQuery()
.Single(); context.DeleteObject(album);
context.SaveChanges(); //delete
context.AttachTo("TableName", photoRow, "*");
context.DeleteObject(photoRow);
context.SaveChanges(); //update
var albumRow = new Album(album);
// attach and update the photo row
context.AttachTo("TableName", albumRow, "*");
context.UpdateObject(albumRow);
context.SaveChanges();

Table Service

        public class Subscriber : TableEntity
{
[Required]
[Display(Name = "List Name")]
public string ListName
{
get
{
return this.PartitionKey; //分区键
}
set
{
this.PartitionKey = value;
}
} [Required]
[Display(Name = "Email Address")]
public string EmailAddress
{
get
{
return this.RowKey;
}
set
{
this.RowKey = value;
}
} public string SubscriberGUID { get; set; } public bool? Verified { get; set; }
}
} var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
var tableClient = storageAccount.CreateCloudTableClient();
var mailingListTable = tableClient.GetTableReference("mailinglist");
mailingListTable.CreateIfNotExists(); //获取Get
var retrieveOperation = TableOperation.Retrieve<T>(_partitionKey, _rowKey);
var retrievedResult = mailingListTable.Execute(retrieveOperation);
return retrievedResult.Result as T; //GetList
string filter = TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, _partitionKey),
TableOperators.And,
TableQuery.GenerateFilterCondition("SubscriberGUID", QueryComparisons.Equal, subscriberGUID));
var query = new TableQuery<Subscriber>().Where(filter);
var subscribers = mailingListTable.ExecuteQuery(query).ToList(); //添加 Add
var insertOperation = TableOperation.Insert(newSubscriber);
mailingListTable.Execute(insertOperation); //Update Or Insert
var upsertOperation = TableOperation.InsertOrReplace(emailRowInTable);
mailingListTable.Execute(upsertOperation); //Update
replaceOperation = TableOperation.Replace(emailRowInTable);
mailingListTable.Execute(replaceOperation); //Delete
var deleteOperation = TableOperation.Delete(emailRowToDelete);
mailingListTable.Execute(deleteOperation);

Sotrage.Tables

   var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
var queueClient = storageAccount.CreateCloudQueueClient();
foreach(var q in queueClient.ListQueues()){//所有队列
var msg = q.GetMessage();
var id = msg.Id;
var name=q.Name; //队列名字:azuremailsubscribequeue
} subscribeQueue = queueClient.GetQueueReference("azuremailsubscribequeue");
subscribeQueue.CreateIfNotExists(); subscribeQueue.AddMessage(new CloudQueueMessage(newSubscriber.SubscriberGUID + "," + newSubscriber.ListName)); msg = subscribeQueue.GetMessage(); subscribeQueue.DeleteMessage(msg); public class WorkerRole : RoleEntryPoint
{ }

CloudQueue

 using System.Net;
using System.Net.Mail;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.Queue;
using Microsoft.WindowsAzure.Storage.Table;
using SendGridMail;
using SendGridMail.Transport; var storageAccount=CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); private static void SendSubscribeEmail(string subscriberGUID, Subscriber subscriber, MailingList mailingList)
{
var email = SendGrid.GenerateInstance();
email.From = new MailAddress(mailingList.FromEmailAddress);
email.AddTo(subscriber.EmailAddress);
string subscribeURL = RoleEnvironment.GetConfigurationSettingValue("AzureMailServiceURL") +
"/subscribe?id=" + subscriberGUID + "&listName=" + subscriber.ListName;
email.Html = String.Format("<p>Click the link below to subscribe to {0}. " +
"If you don't confirm your subscription, you won't be subscribed to the list.</p>" +
"<a href=\"{1}\">Confirm Subscription</a>", mailingList.Description, subscribeURL);
email.Text = String.Format("Copy and paste the following URL into your browser in order to subscribe to {0}. " +
"If you don't confirm your subscription, you won't be subscribed to the list.\n" +
"{1}", mailingList.Description, subscribeURL);
email.Subject = "Subscribe to " + mailingList.Description;
var credentials = new NetworkCredential(RoleEnvironment.GetConfigurationSettingValue("SendGridUserName"), RoleEnvironment.GetConfigurationSettingValue("SendGridPassword"));
var transportREST = REST.GetInstance(credentials);
transportREST.Deliver(email);
} private string GetBlobText(string blogRef)
{
var blob = blobContainer.GetBlockBlobReference(blogRef);
blob.FetchAttributes();
var blobSize = blob.Properties.Length;
using (var memoryStream = new MemoryStream((int)blobSize))
{
blob.DownloadToStream(memoryStream);
return System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
}
} //upload image (stream)
var blob = container.GetBlobReference(file);
blob.Properties.ContentType = mimeType;
blob.UploadFromStream(binary); //down image
var client = this.storageAccount.CreateCloudBlobClient();
var container = client.GetContainerReference(owner); using (var ms = new MemoryStream())
{
container.GetBlobReference(file).DownloadToStream(ms);
var image = Image.FromStream(ms);
} // save it off to blob storage
using (var thumbStream = new MemoryStream())
{
thumb.Save(
thumbStream,
System.Drawing.Imaging.ImageFormat.Jpeg); thumbStream.Position = ; // reset; var thumbBlob = container.GetBlobReference(Path.Combine("thumb", file));
thumbBlob.Properties.ContentType = "image/jpeg";
thumbBlob.UploadFromStream(thumbStream);
} //use image
var blobUri = client.GetContainerReference(owner).GetBlobReference(file).Uri.ToString();
var thumbUri = client.GetContainerReference(owner).GetBlobReference(Path.Combine("thumb", file)).Uri.ToString(); //delete var blobGone = container.GetBlobReference(filename).DeleteIfExists();
var thumbGone = container.GetBlobReference(thumbname).DeleteIfExists();

Storage.Blob

windows azure 实例的更多相关文章

  1. Windows Azure 名词定义(Glossary)

    Glossary(名词) Definition(定义) Availability Set 可用性组 refers to two or more Virtual Machines deployed ac ...

  2. CSV 客座文章系列: Pruffi 通过 Windows Azure 挖掘社交媒体的强大招聘潜能

    编辑人员注释:今天这篇文章由 Pruffi 创始人 Alena Vladimirskaya 和 Pruffi 的 CTO Alexander Ivanov 联合撰写,介绍了该公司如何使用 Window ...

  3. CSV 客座文章系列:KGroup 通过 Windows Azure 将 Qoob 内容管理发布到云中

    编辑人员注释: 今天这篇文章由 KGroup 首席软件架构师兼研发部主管 Jody Donetti 与 KGroup 技术总监 Simone Procopio 共同撰写,介绍了 KGroup 如何使用 ...

  4. Windows Azure Virtual Machine (28) 使用Azure实例级别IP,Instance-Level Public IP Address (PIP)

    <Windows Azure Platform 系列文章目录> 本文介绍的是国内由世纪互联运维的Azure China 熟悉Azure平台的读者都知道,我们在使用Azure Virtual ...

  5. Windows Azure虚拟机和云服务实例计费方式更新

    在之前的Windows Azure计费账单中,A0,A1,A2,A3,A4系列的虚拟机(云服务实例)都是以A1为基准计费单位的,即: 虚拟机大小 计费单位(小时) A0 A1*0.25 A1 A1*1 ...

  6. 宣布在 Azure 镜像库中正式推出 Windows Server 2012 R2 并降低 Windows Azure 的实例定价

    我们今天将宣布两条消息,为使用基础结构服务的客户提供更多选择和成本节约:在镜像库中推出 Windows Server 2012 R2 以及降低 Memory Intensive 计算实例定价. 虚拟机 ...

  7. 禁用 Windows Azure 网站中的 ARR 实例关联

    编辑人员注释: 本博客文章由 Windows Azure 网站团队的项目经理 Erez Benari 撰写. 在 Windows Azure 网站中设置网站的多个实例是横向扩展网站的绝佳方式,Azur ...

  8. 简化 Web 应用程序与 Windows Azure Active Directory、ASP.NET 和 Visual Studio 的集成

    大家好! 今天的博文深入讨论我们今天推出的开发人员工具和框架中的一些新功能.我们通过与 ASP.NET 和 Visual Studio 团队合作开发了一些重大的增强功能,让开发人员能够轻松使用 Win ...

  9. 今天Windows Azure Live to Code的分享

    今天参加了微软广州的Live to Code,晚上回公司OT写了封报告E-mail,也没让公司今天白出工资给我... 因为没有涉及到公司机密什么的,所以就拿出来跟大家分享一下. 首先要说明的是,在会议 ...

随机推荐

  1. Linux解压缩总结

    看文件名的后缀名,不同的后缀的文件解压和压缩的命令都不一样总结如下: *.tar 用 tar –xvf 解压 *.gz 用 gzip -d或者gunzip 解压 *.tar.gz和*.tgz 用 ta ...

  2. django user模块改写

    示例一:继承AbstractBaseUser,AbstractBaseUser只有三个字段password,last_login,is_active,以及需要复习的两个方法 def get_full_ ...

  3. mongoDB初接触

    首先去官网http://www.mongodb.org/ 下载mongoDB 下载后解压D:\mongodb 创建两个新文件夹data以及log 新建一个文件命名为mongodb.cfg dbpath ...

  4. Startup 和 Middleware(中间件)

    Startup 和 Middleware(中间件) ASP.NET Core 运行原理剖析2:Startup 和 Middleware(中间件) Startup Class 1.Startup Con ...

  5. pycurl,Python cURL library

    pycurl — A Python interface to the cURL library Pycurl包是一个libcurl的Python接口.pycurl已经成功的在Python2.2到Pyt ...

  6. 解题报告 HDU1087 Super Jumping! Jumping! Jumping!

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  7. imagemagick /tmp/magick-xxxxxxxx

    问题 imagemagick在某种场景下会狂写/tmp目录,文件名形如magick-xxxxxxxx, ls -lh查看这些文件达到几百G, du -sh查看则只有几十M 被这个问题折磨了许久,大晚上 ...

  8. Robot Framework学习路线

    0. 官方网站  http://robotframework.org/ 所有资料都来自这里,从这里找到必要的链接,从而深入其中的细节. 1.  Quick Start Guide https://co ...

  9. Android百度地图定位

    在谈到百度地图.如今,每个人都知道这个时候应该可以了吧.而更多的字不拉.直接朝话题. 访问百度地图api您必须应用key,应用在这里key不用说,有官方的文件说明如何应用上述key. 在这里,百度地图 ...

  10. 【Eclipse】Failed to load the JNI shared library

    这是因为JDK配置错误所导致的现象. 一般说来,新购笔记本会预装64位的windows系统,而在网上下载软件时,32位会优先出现在页面中(现在来说是这个情况,但我认为未来64位会越来越普及). 如果你 ...