azure - 使用方法 : Create role instances on emulator

标签 azure emulation roles

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

到目前为止我知道:

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

UPD 明白了。

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

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

其中部署ID:

    // 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

最佳答案

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

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

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

关于azure - 使用方法 : Create role instances on emulator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9166188/

相关文章:

azure - 无需登录即可使用 Azure API(使用角色)

google-cloud-platform - Google Storage Bucket 允许查看对象但不能列出

python - 通过python API获取Windows Azure存储表名称

emulation - 为什么有些模拟器需要 BIOS 转储?

lua - 业务鹰 2.1.1 : read ("*number") always returns 0 in Lua

c# - 如何在我的 asp.net core 3.1 应用程序中播种用户和角色?

.net - Windows Azure 中的 ASP.net 应用程序部署

azure - 错误: Deployment failed: ERROR_DESTINATION_NOT_REACHABLE when deploying to App Service from Azure DevOps Services

azure - 如何让 Azure Devops Pipelines 由 Prs 触发但不由其他提交触发

firebase - 无法使用 fetch() 从 Firebase 模拟器访问 googleapis.com 以外的网址