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学习之查找命令find

    1.find  -name 根据名称查找文件 *通配所有字符: ?统配单个字符 2.find -iname 根据名称不区分大小写 3.find -size  根据文件大小 find / -size + ...

  2. AOI自动光学检测机技术在电路板检查中的应用

    1.简述 AOI技术在许多不同的制造业领域使用,自从电子影像技术开始发展,就被各种人利用在不同的应用领域.大家最熟悉的数字相机.数字摄影机是大家生活中最常用到的器材之一,而工业产品的生产也大量使用这些 ...

  3. Maven2的配置文件settings.xml(转)

    http://maven.apache.org/settings.html简介: 概览当Maven运行过程中的各种配置,例如pom.xml,不想绑定到一个固定的project或者要分配给用户时,我们使 ...

  4. AppCode3 常用 设置 及 快捷键 (持续更新)

    以下设置都可以通过 设置中的搜索框 进行关键字搜索 0, 打开Project 设置 Command + ; 1, 打开设置快捷键 Command + , 2, 显示行号 Editor -> Ap ...

  5. PHP MYSQL数据字典

    <?php /** * 生成mysql数据字典 */ header ( "Content-type: text/html; charset=utf-8" ); // 配置数据 ...

  6. Kruscal 、 Prime Template

    Kruscal  Template : 很裸的Kruscal Template(求最小生成树中最长路,即最短路中最长路) //#pragma comment(linker, "/STACK: ...

  7. CodeForces 385C Bear and Prime Numbers 素数打表

    第一眼看这道题目的时候觉得可能会很难也看不太懂,但是看了给出的Hint之后思路就十分清晰了 Consider the first sample. Overall, the first sample h ...

  8. Qt 5.x 全局热键 for windows

    Qt 升级到5.x版本后,QAbstractEventDispatcher中函数发生变动,导致libqxt库中的qxtGlobalShortcut挂掉.参考qxtGlobalShortcut写了一个全 ...

  9. javascript 入门之简单换肤效果

    大家好,我是小强老师,这里简单入门 做一个换肤效果 效果如图所示: 这个案例思路分为两部分: 获取元素对象. var pic1 = document.getElementById('pic1'); v ...

  10. Windows Phone 8初学者开发—第18部分:在页面间导航

    原文 Windows Phone 8初学者开发—第18部分:在页面间导航 原文地址:  http://channel9.msdn.com/Series/Windows-Phone-8-Developm ...