使用 PowerShell 将应用部署到服务结构
Deploy app to service fabric with PowerShell
我已在 Azure 中启动并 运行ning 服务结构。我还有 Visual Studio 两个项目的解决方案:Service Fabric 和 Web Service。
我想将服务部署到 Azure 中的服务结构。
当我右键单击我的服务结构项目并单击 "Publish" 时,服务顺利部署到云结构。我想对 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
在 运行 运行脚本之前,我右键单击我的 fabric 应用程序并 select "Package"。
我脚本的最后一个命令失败 "application not found"
什么可以缺少?
构建并准备好包后,您可以尝试使用以下命令使用 PowerShell 脚本部署 pkg。
如果您还没有尝试过以下选项,请试试看它是否有效。
运行脚本所需的先决条件很少:
您的集群已启动并 运行正在运行。
集群部署了所有必要的证书(例如 SSL
端点,如果有的话)
您已准备好 ARM 模板和参数文件。
您拥有部署新资源所需的权限,
即贡献者角色(在订阅或资源级别
组)
您已创建目标资源组
检查完以上内容后,执行以下命令:
Copy-ServiceFabricApplicationPackage
注册-ServiceFabricApplicationType
新建 ServiceFabricApplication
如果这对您不起作用,请浏览以下网站看看是否有帮助。
Deploy applications using PowerShell
Deploy resources with Resource Manager templates and Azure PowerShell
问题是我在命令 New-ServiceFabricService
.
中使用了错误的 ApplicationName
和 ServiceName
为了找出正确的值是什么,我 运行 Get-ServiceFabricApplication
和 Get-ServiceFabricService
.
这些页面对于构建脚本故障排除非常有帮助:
我已在 Azure 中启动并 运行ning 服务结构。我还有 Visual Studio 两个项目的解决方案:Service Fabric 和 Web Service。 我想将服务部署到 Azure 中的服务结构。 当我右键单击我的服务结构项目并单击 "Publish" 时,服务顺利部署到云结构。我想对 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
在 运行 运行脚本之前,我右键单击我的 fabric 应用程序并 select "Package"。
我脚本的最后一个命令失败 "application not found"
什么可以缺少?
构建并准备好包后,您可以尝试使用以下命令使用 PowerShell 脚本部署 pkg。
如果您还没有尝试过以下选项,请试试看它是否有效。
运行脚本所需的先决条件很少:
您的集群已启动并 运行正在运行。
集群部署了所有必要的证书(例如 SSL 端点,如果有的话)
您已准备好 ARM 模板和参数文件。
您拥有部署新资源所需的权限, 即贡献者角色(在订阅或资源级别 组)
您已创建目标资源组
检查完以上内容后,执行以下命令:
Copy-ServiceFabricApplicationPackage
注册-ServiceFabricApplicationType
新建 ServiceFabricApplication
如果这对您不起作用,请浏览以下网站看看是否有帮助。
Deploy applications using PowerShell
Deploy resources with Resource Manager templates and Azure PowerShell
问题是我在命令 New-ServiceFabricService
.
ApplicationName
和 ServiceName
为了找出正确的值是什么,我 运行 Get-ServiceFabricApplication
和 Get-ServiceFabricService
.
这些页面对于构建脚本故障排除非常有帮助: