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. KVM镜像管理利器-guestfish使用详解

    原文  http://xiaoli110.blog.51cto.com/1724/1568307   KVM镜像管理利器-guestfish使用详解 本文介绍以下内容: 1. 虚拟机镜像挂载及w2k8 ...

  2. 门面(Facade)模式--医院,保安系统实例

    门面(Facade)模式 http://www.cnblogs.com/zhenyulu/articles/55992.html

  3. Iframe知识点

    var oIframe=document.getElementById('iframe1'); 获取iframe对象:   oIframe.contentWindow.//  iframe 里的win ...

  4. 设计模式总结1--observer pattern

    <!-- 设计模式 --><!--是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了可重用代码.让代码更容易被他人理解.保证代 码可靠性 --&g ...

  5. 杭电 HDU 1242 Rescue

    http://acm.hdu.edu.cn/showproblem.php?pid=1242 问题:牢房里有墙(#),警卫(x)和道路( . ),天使被关在牢房里位置为a,你的位置在r处,杀死一个警卫 ...

  6. 【IPC进程间通信之四】数据复制消息WM_COPYDATA

    IPC进程间通信+数据复制消息WM_COPYDATA                IPC(Inter-Process Communication,进程间通信).         数据复制消息WM_C ...

  7. AFNetworking 3.0x版本最新特性

    AFNetworking是一款在OS X和iOS下都令人喜爱的网络库.为了迎合iOS新版本的升级, AFNetworking在3.0版本中删除了基于 NSURLConnection API的所有支持. ...

  8. 素数环(C - 暴力求解)

    素数环(暴力)(紫书194页) Description   A ring is composed of n (even number) circles as shown in diagram. Put ...

  9. BZOJ 3282: Tree( LCT )

    LCT.. -------------------------------------------------------------------------------- #include<c ...

  10. MySQL 出现 The table is full 的解决方法

    原文链接: MySQL 出现 The table is full 的解决方法 浅谈MySql的存储引擎(表类型) MySQL 出现 The table is full 只有一个原因,对应的表数据容量达 ...