【问题标题】:Windows Azure Storage - Table not foundWindows Azure 存储 - 未找到表
【发布时间】:2013-01-01 02:48:17
【问题描述】:

我正在尝试实现 Windows azure 表存储...但我得到 'Table Not Found'

这是我的连接字符串(如何在此处发布我的 xml?)(抱歉链接)

ServiceConfiguration.Cloud.cscfg: http://pastebin.com/F9tuckfT

ServiceConfiguration.Local.cscfg:

http://pastebin.com/XZHEvv6g

这里有一个来自我的 Windows azure 门户的打印屏幕

http://s20.postimage.org/nz1sxq7hp/print.png

代码(抱歉代码较长...但是有三页...登录有效,当我登录时,转到调用 grid.aspx 的 main.aspx ...在 grid.aspx 中出现错误“找不到表”所有这些代码对于这个问题都很重要.....)http://pastebin.com/RnuvvqsM

我试过了

private void popula()
    {
        var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
        account.CreateCloudTableClient().CreateTableIfNotExist("fiscal");
        var context = new CRUDManifestacoesEntities(account.TableEndpoint.ToString(), account.Credentials);

        Hashtable ht = (Hashtable)ViewState["filtro"];

        if (ht == null)
            GridView1.DataSource = context.SelectConc(ViewState["x"].ToString());
        else
            GridView1.DataSource = context.SelectConc(ht);

        GridView1.DataBind();
    }

但它也不起作用

其他类似的错误是当我尝试在表中添加用户时

public string addusr(string nome, string cidade, string cpf, string email, string telefone)
    {
        try
        {
            if (nome.Length == 0)
                return "f:Preencha o campo nome.";

            if (cidade.Length == 0)
                return "f:Preencha o campo cidade.";

            if (cpf.Length == 0)
                return "f:Preencha o campo cpf.";

            if (!Valida(cpf))
                return "f:CPF Invalido.";

            if (email.Length == 0)
                return "f:Preencha o campo email.";

            Regex rg = new Regex(@"^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$");
            if (!rg.IsMatch(email))
            {
                return "f:Email Invalido";
            }

            List<UserEntity> lst = new List<UserEntity>();
            var _account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
            _account.CreateCloudTableClient().CreateTableIfNotExist("fiscal");
            var _context = new CRUDUserEntities(_account.TableEndpoint.ToString(), _account.Credentials);


            var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
            account.CreateCloudTableClient().CreateTableIfNotExist("fiscal");
            var context = new CRUDUserEntities(account.TableEndpoint.ToString(), account.Credentials);
            UserClientEntity entity = new UserClientEntity() { nome = nome, cidade = cidade, cpf = cpf, email = email, telefone = telefone };
            context.ADDUSociate(entity);
            context.SaveChanges();
            return "k";
        }

我收到此错误: f: 处理此请求时发生错误。|在 System.Data.Services.Client.DataServiceContext.SaveResult.HandleBatchResponse() 在 System.Data.Services.Client.DataServiceContext.SaveResult.EndRequest() 在 System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions 选项) 在 AzureTableLayer.CRUDUserEntities.ADDUSociate(UserClientEntity 实体) 在 mobile.Service1.addusr(字符串名称,字符串 cidade,字符串 cpf,字符串电子邮件,字符串电话)

我认为这两个问题是相关的

编辑:我已经调试并发现无法加载 StorageClient 框架... 我收到此错误无法加载文件或程序集 Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

如何解决?

【问题讨论】:

  • 在我回答之前,我看到您已经在配置文件中包含了实际凭据。请从配置文件中删除它或重新生成您的帐户密钥以避免滥用您的存储帐户。
  • 你能分享你得到这个错误的代码吗?

标签: visual-studio azure azure-storage


【解决方案1】:

您如何尝试使用表存储?使用 .NET SDK? php?爪哇?节点? ...通常,如果您收到此错误,则意味着...该表不存在。

检查您正在使用的 SDK 是否有类似于 CreateIfNotExists 的方法,以便在开始使用之前创建表。

编辑:

问题可能发生在这里:

        var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
        var context = new CRUDManifestacoesEntities(account.TableEndpoint.ToString(), account.Credentials);

        Hashtable ht = (Hashtable)ViewState["filtro"];

        if (ht == null)
            GridView1.DataSource = context.SelectConc(ViewState["x"].ToString());
        else
            GridView1.DataSource = context.SelectConc(ht);

在 var account = ... 行之后添加以下代码:

     account.CreateCloudTableClient().CreateTableIfNotExist("<name of your table>");

【讨论】:

  • 如果是Windows Azure表存储,只能是.net
  • 不,Windows Azure 是一个开放平台,不会限制您使用 .NET - 有很多可用的 SDK,例如用于 Node.js:windowsazure.com/en-us/develop/nodejs/how-to-guides/…
  • 请给我们一些代码。您唯一需要做的可能就是像 table.CreateIfNotExist(); 这样来解决您的问题。
  • 我正在尝试 protected void Page_Load(object sender, EventArgs e) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn")); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve a reference to a container CloudBlobContainer container = blobClient.GetContainerReference("fiscal"); // Create the container if it doesn't already exist container.CreateIfNotExist(); } 正在上传...
  • 请将它添加到您的问题中(很难像这样阅读)。还要尝试解释您正在尝试做什么以及失败的地方。
【解决方案2】:

API 已更改。你需要这样做:

var key = CloudConfigurationManager.GetSetting("Setting1");
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(key);
var client = storageAccount.CreateCloudTableClient();

CloudTable table = client.GetTableReference(ContactTableName);
table.CreateIfNotExists();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-21
    • 2011-09-18
    • 2022-08-24
    • 2023-03-23
    • 2012-09-19
    • 1970-01-01
    • 2017-11-08
    • 2015-04-29
    相关资源
    最近更新 更多