将Azure webrole部署到云,但不理解数据连接字符串(用于队列)
我已经编写了一个测试应用程序并将其成功部署到天蓝色云,但现在我已经向该应用程序添加了一个队列,我迷失了方向。
目前我使用配置字符串:
Setting name="DataConnectionString" value="UseDevelopmentStorage=true"
然后使用以下代码创建/打开队列:
var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
var queueClient = storageAccount.CreateCloudQueueClient();
var queue = queueClient.GetQueueReference("messagequeue");
queue.CreateIfNotExist();
这在本地模式下工作正常,但是, 我不明白如何更改 DataConnectionString 以使用云!
我已经尝试过:
Setting name="DataConnectionString" value="DefaultEndpointsProtocol=http;AccountName=*XXXXX*;AccountKey=*YYYYY*"
但这不起作用 - 它不会在本地运行。 非常感谢您的帮助!
谢谢
I have written and successfully deployed a test app to the azure cloud, but I am lost now that I have added a queue to the application.
Currently I using a configuration string:
Setting name="DataConnectionString" value="UseDevelopmentStorage=true"
then create/open the queue with the following code:
var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
var queueClient = storageAccount.CreateCloudQueueClient();
var queue = queueClient.GetQueueReference("messagequeue");
queue.CreateIfNotExist();
This works fine in local mode, however,
I do not undertsand how to change the DataConnectionString to use the cloud!
I have tried:
Setting name="DataConnectionString" value="DefaultEndpointsProtocol=http;AccountName=*XXXXX*;AccountKey=*YYYYY*"
but this does not work - it wont run locally.
Help is certainly appreciated!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要确保已通过 Windows Azure 门户创建托管的 Azure 存储服务。创建存储服务时,您提供帐户名,系统将分配两个密钥。在连接字符串设置中使用这两个值。您可以在服务配置中手动编辑字符串,或者我的首选方法是通过角色的属性设置来设置它。只需在 Visual Studio 中右键单击云服务项目中的角色,然后选择属性即可。您将能够通过选项卡之一访问角色的设置。使用提供的对话框通过输入存储服务的帐户名和连接字符串来修改连接字符串。
You'll need to make sure you've created a hosted azure storage service via the Windows Azure portal. When creating the storage service, you provide the account name and the system will assign two keys. Use these two values in your connection string settings. You can either manually edit the string in the service configuration, or my preferred approach is to set it via the role's property settings. Simply right click on the role in the cloud service project in visual studio, then select properties. You'll be able to access the role's settings via one of the tabs. Use the provided dialog box to modify the connection string by inputing the account name and connection string for your storage service.