问题: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,我无法改变它。
下一步是将队列存储重新配置为不使用 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>
...
关闭并启动存储模拟器,一切都应该很好:
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();
所以经过一段时间的调整... 我还注意到我的队列命名很糟糕(一旦我让客户端连接,它就会返回 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();