powershell - 使用 PowerShell 将应用程序部署到服务结构
问题描述
我在 Azure 中启动并运行了服务结构。我也有两个项目的 Visual Studio 解决方案:Service Fabric 和 Web Service。我想将服务部署到 azure 中的服务结构。当我右键单击我的服务结构项目并单击“发布”时,服务会顺利部署到云结构。我想对 PowerShell 做同样的事情。
看来我需要运行这个脚本:
# Connect to the cluster using a client certificate.
Connect-ServiceFabricCluster -ConnectionEndpoint $endpoint `
-KeepAliveIntervalInSec 10 `
-X509Credential -ServerCertThumbprint $thumbprint `
-FindType FindByThumbprint -FindValue $thumbprint `
-StoreLocation CurrentUser -StoreName My
# Copy the application package to the cluster image store.
Copy-ServiceFabricApplicationPackage $packagepath -ImageStoreConnectionString fabric:ImageStore -ApplicationPackagePathInImageStore $packagename
# Register the application type.
Register-ServiceFabricApplicationType -ApplicationPathInImageStore $packagename
# Create the service instance.
$appName = <name that I see in fabric explorer under 'typeName' in azure>
New-ServiceFabricService -ApplicationName fabric:/$appName -ServiceName fabric:/$appName/MyApp -ServiceTypeName $serviceTypeName -Stateless -PartitionSchemeSingleton -InstanceCount -1
在运行脚本之前,我右键单击我的织物应用程序并选择“包”。
我的脚本的最后一个命令因“找不到应用程序”而失败
可以缺少什么?
解决方案
构建并准备好包后,您可以尝试以下命令以使用 PowerShell 脚本部署 pkg。
如果您还没有尝试过以下选项,请尝试一下,看看它是否有效。
运行脚本需要几个先决条件:
您已启动并运行集群。
集群已部署所有必要的证书(例如 SSL 端点,如果有)
您已准备好 ARM 模板和参数文件。
您拥有部署新资源所需的权限,即 Contributor 角色(订阅或资源组级别)
您已创建目标资源组
检查上述内容后,执行以下命令:
Copy-ServiceFabricApplicationPackage
注册-ServiceFabricApplicationType
新ServiceFabricApplication
如果这对您不起作用,请浏览以下站点以查看是否有帮助。
推荐阅读
- github - 我可以在 GitHub 上查看我自己的拉取请求吗?
- angular - Npm 安装构建失败
- c# - 聚合包含表达式上的实体框架“代码应该无法访问”
- html - 如何在不同屏幕分辨率下的相同位置显示 CSS 属性“位置:固定”?
- php - (也许)停止启动 foreach 循环以修复 Bootstrap 结构
- javascript - meteo.js:21 Uncaught SyntaxError: await 仅在异步函数中有效
- css - Angular 添加主题 scss 以覆盖全局样式
- swift - 运行仅 iPhone 应用程序的 iPad 对应于哪款 iPhone?
- php - 多个 MySQL 查询需要大量时间来加载页面
- nunit - Namespce OneTimeTearDownAttirbute () 和 OneTimeSetUpttirbute () 在 NUnit.Framework 中不存在,在自动生成的 specflow(.cs) 文件中显示错误