操作方法:在模拟器上创建角色实例

发布于 2025-01-03 04:34:40 字数 1099 浏览 3 评论 0原文

如何使用 Azure 模拟器通过 C# 创建某个角色的新实例?有一些关于这方面的指南吗?有一些关于在云中而不是在模拟器中创建实例的手册。

到目前为止我知道:

  • 我需要更改配置文件。它是在 sln 文件中还是在某个临时部署文件夹中配置的?
  • 我需要使用 csrun 工具。如何选择参数?

UPD 知道了。

要更改模拟器上的计数或实例,您必须:

  • 更新 bin 文件夹中的“ServiceConfiguration.cscfg”文件
  • 使用参数运行“csrun”工具: string.Format("/update:{0};\"{1 }\“”,deploymentId,“”)

其中deploymentId:

    // get id from RoleEnvironment with regex 
    var patternt = Regex.Escape("(") + @"\d+" + Regex.Escape(")");
    var input = RoleEnvironment.DeploymentId;
    var m = Regex.Match(input, patternt);
    var deploymentId = m.ToString().Replace("(", string.Empty).Replace(")", string.Empty);

如果您在通过代码运行csrun时遇到问题,请阅读以下内容: http://social.msdn.microsoft.com/Forums/en/windowsazuredevelopment/thread/62ca1372-2388-4181-9dbd-8fbba470ea77

How do I create new instances of some role via C# using Azure emulator? Is there some guide about that? There are some manuals about creating instances in the cloud, not in emulator.

So far I know that:

  • I need to change config-file. Is it config in sln-file or in some temp-delpoyment folder?
  • I need to use csrun tool. How to pick params?

UPD
Got it.

To change count or instances on emulator, you have to:

  • update 'ServiceConfiguration.cscfg' file in bin-folder
  • run 'csrun' tool with params: string.Format("/update:{0};\"{1}\"", deploymentId, "<path to ServiceConfiguration.cscfg>")

where deploymentId:

    // get id from RoleEnvironment with regex 
    var patternt = Regex.Escape("(") + @"\d+" + Regex.Escape(")");
    var input = RoleEnvironment.DeploymentId;
    var m = Regex.Match(input, patternt);
    var deploymentId = m.ToString().Replace("(", string.Empty).Replace(")", string.Empty);

If you have troubles running csrun via code, read this:
http://social.msdn.microsoft.com/Forums/en/windowsazuredevelopment/thread/62ca1372-2388-4181-9dbd-8fbba470ea77

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白衬杉格子梦 2025-01-10 04:34:40

在本地模拟器中,您需要修改部署 .csx 文件夹(而不是源代码文件夹)下的 CSCFG 文件,因为本地模拟器将从该文件夹启动您的应用程序。

修改保存的 CSCFG 文件后,例如实例计数,您可以立即从代码中检索新值。但如果您希望本地模拟器检测到此更改并执行相关操作,例如增加虚拟机或调用 Configuration_Changed 方法,则需要执行
csrun /更新:;

您可以从计算模拟器 UI 检索部署 ID。

In local emulator, you need to modify the CSCFG file under the deployment .csx folder, instead of your source code folder, since the local emulator will fire your application up from that folder.

Once you modified the saved your CSCFG file, for example the count of the instances you can retrieve the new value from your code immediately. But if you want the local emulator detect this changes and perform the related actions, such as increase the VMs or invoke the Configuration_Changed method, you need to execute
csrun /update:;

You can retrieve the deployment id from the compute emulator UI.

一花一树开 2025-01-10 04:34:40

您可以在 Azure 项目的 ServiceConfiguration.cscfg 中找到实例计数

You can find the instance count in the ServiceConfiguration.cscfg in your Azure project

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文