Azure SDK 1.7存储模拟器 - 队列存储无法启动 - 使用带有dev env自定义端口的Storage Client

时间:2012-10-30 15:35:05

标签: azure azure-storage

问题:Azure存储模拟器可以启动Blob和表存储,但队列存储将无法启动,显示错误对话框: “文件正被另一个进程使用” 找到解决该问题的方法,但现在我的开发环境存储客户端出现了问题。这就是我所做的......

端口10001是队列存储的默认端口,因此根据我做的一些相关文章(输出中的最后一列是进程的PID):

    c:\...> netstat -p tcp -ano | findstr :1000
  TCP    0.0.0.0:10001          0.0.0.0:0              LISTENING       2628
  TCP    127.0.0.1:10000        0.0.0.0:0              LISTENING       4
  TCP    127.0.0.1:10002        0.0.0.0:0              LISTENING       4

这里最大的问题是,10001上的监听是McAfee,我无法改变它。

下一步是将Queue存储重新配置为不使用10001: 重新配置存储模拟器以侦听可用端口。打开:

%PROGRAMFILES%\Microsoft SDKs\Windows Azure\Emulator\devstore\DSServiceLDB.exe.config

在您喜欢的文本编辑器中更改队列存储的绑定...在我的情况下,10003可用:

<?xml version="1.0"?>
<configuration>
  <configSections>    
    <section name="developmentStorageConfig" type="Microsoft.ServiceHosting.DevelopmentStorage.Utilities.DevelopmentStorageConfigurationHandler, DevelopmentStorage.Common"/>
  </configSections>

  <developmentStorageConfig>
    <services>
      <service name="Blob" url="http://127.0.0.1:10000/"/>
      <service name="Queue" url="http://127.0.0.1:10003/"/> <!-- this line here -->
      <service name="Table" url="http://127.0.0.1:10002/"/>
    </services>
...

shutodwn并启动存储模拟器,一切都应该是好的:

c:\...netstat -p tcp -ano | findstr :1000
  TCP    0.0.0.0:10001          0.0.0.0:0              LISTENING       2628
  TCP    127.0.0.1:10000        0.0.0.0:0              LISTENING       4
  TCP    127.0.0.1:10002        0.0.0.0:0              LISTENING       4
  TCP    127.0.0.1:10003        0.0.0.0:0              LISTENING       4

现在,尝试在VS2012中配置我的客户端无效... 我修改了配置文件:ServiceConfiguration.Cloud.cscfg 使用以下设置:

<Setting name="StorageConnectionString" value="BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10003/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount;AccountName=devstoreaccount;AccountKey=key copied from storage config file" />

但是当我尝试连接到队列并且调用create(如果不存在)时,我得到404:

    storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
    queueClient = storageAccount.CreateCloudQueueClient();
    queue = queueClient.GetQueueReference("testqueue");
    queue.CreateIfNotExist();

所以经过一段时间的调整...... 我查看了存储客户端在使用开发设置时所做的事情,并使用System.Diagnostics.Debugger.IsAttached块复制了代码。我还注意到我的队列命名很糟糕(一旦我让客户端连接,它就会回复400错误):

if (System.Diagnostics.Debugger.IsAttached)
        {
            var blobEndpoint = new Uri("http://127.0.0.1:10000/devstoreaccount1");
            var queueEndpoint = new Uri("http://127.0.0.1:10003/devstoreaccount1");
            var tableEndpoint = new Uri("http://127.0.0.01:10002/devstoreaccount1");
            var storageCreds = new StorageCredentialsAccountAndKey("devstoreaccount1", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==");

            _storageAccount = new CloudStorageAccount(storageCreds, blobEndpoint, queueEndpoint, tableEndpoint);
        }
        else
        {
            _storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
        }
        _queueClient = _storageAccount.CreateCloudQueueClient();
        /* Queue naming rules:
         *  1. A queue name must start with a letter or number, and can only contain letters, numbers, and the dash (-) character. 
            2. The first and last letters in the queue name must be alphanumeric. The dash (-) character cannot be the first or last character. Consecutive dash characters are not permitted in the queue name.
            3. All letters in a queue name must be lowercase.
            4. A queue name must be from 3 through 63 characters long.
         */
        _queue = _queueClient.GetQueueReference("myqueuename");
        _queue.CreateIfNotExist();  

1 个答案:

答案 0 :(得分:1)

查看此目录(C:\ Program Files \ Microsoft SDKs \ Windows Azure \ Emulator \ devstore)并更改DSServiceLDB.exe.config中的端口配置:

<services>
<service name="Blob" url="http://127.0.0.1:10000/"/>
<service name="Queue" url="http://127.0.0.1:10003/"/>
<service name="Table" url="http://127.0.0.1:10002/"/>
</services>

我和10001有同样的问题。