Windows Azure Table に日本語のデータを登録すると例外が発生するので、Base64でエンコードしていたのですが、先日行われたVSUG DAY で 「本番環境では登録できる」という感じの話が聞こえてきたので確かめてみました。
下記のようなコードを実行したところ
using System;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
using System.Data.Services.Client;
namespace WebRole1.Storage
{
public partial class sample3 : System.Web.UI.Page
{
private CloudStorageAccount account = CloudStorageAccount.FromConfigurationSetting("StorageConnectionString");
protected void Page_Load(object sender, EventArgs e)
{
CloudTableClient tableClient = account.CreateCloudTableClient();
tableClient.RetryPolicy = RetryPolicies.Retry(
2,
TimeSpan.FromMilliseconds(100));
tableClient.CreateTableIfNotExist("SampleTable");
Table1 t1 = new Table1();
t1.Name = "田中太郎";
TableServiceContext svc = tableClient.GetDataServiceContext();
svc.AddObject("SampleTable", t1);
try
{
svc.SaveChanges();
}
catch (DataServiceRequestException ex)
{
TextBox1.Text = "失敗\r\n" + ex.ToString();
return;
}
Response.Write("成功");
}
private class Table1 : TableServiceEntity
{
public string Name { get; set; }
public Table1()
{
base.PartitionKey = "Sample";
base.RowKey = Guid.NewGuid().ToString(); ;
}
}
}
}
Development Storageでは、やはり例外が発生しますが
本番環境では、日本語のデータも登録できました。
