azure - 如何将 WebPublish 与 Github 操作结合使用到 .NET Core 应用程序的 IIS 服务器?

标签 azure deployment github-actions webdeploy

我有一个 .NET Core 6.0 Web 应用程序,我正在使用 GoDaddy's windows deluxe hosting这让我可以使用 Plesk 来管理我的网站。我可以下载一个*.publishsettings我拥有的每个网站的文件,如下所示

<?xml version="1.0"?>
<publishData>
  <publishProfile profileName="example.com - Web Deploy"
                  publishMethod="MSDeploy" 
                  publishUrl="https://example.com:8172/msdeploy.axd?site=example.com" 
                  msdeploySite="example.com"
                  userName="<redacted>"
                  destinationAppUrl="http://example.com" 
                  controlPanelLink="https://example.shr.prod.phx3.secureserver.net:8443"
  />
</publishData>

当我将其导入 Visual Studio 时,它会生成此 *.pubxml文件,我在其中添加了 <UserPWD>节点。

<Project>
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>http://example.com</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
    <ExcludeApp_Data>false</ExcludeApp_Data>
    <ProjectGuid>c16666a7-f6aa-406d-af77-effb1be3f08f</ProjectGuid>
    <MSDeployServiceURL>https://example.com:8172/msdeploy.axd?site=example.com</MSDeployServiceURL>
    <DeployIisAppPath>example.com</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>true</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <EnableMSDeployBackup>true</EnableMSDeployBackup>
    <EnableMsDeployAppOffline>true</EnableMsDeployAppOffline>
    <UserName>REDACTED</UserName>
    <UserPWD>REDACTED</UserPWD>
    <_SavePWD>true</_SavePWD>
    <TargetFramework>net6.0</TargetFramework>
    <SelfContained>false</SelfContained>
  </PropertyGroup>
</Project>

我已经保存了 *.pubxml文件作为 github secret ,名为 PUBLISH_PROFILE_PROD ,然后我使用 Azure webapps-deploy action 进行部署的 github 操作

name: 🚀 Deploy website to PROD
on:
  workflow_dispatch:
  push:
    branches: [main]
    paths-ignore: [".vscode/**", "README.md", ".*"]
permissions:
  contents: write
jobs:
  web-deploy:
    name: 🎉 Deploy Prod
    runs-on: ubuntu-latest
    steps:
      - name: 🚚 Get latest code
        uses: actions/checkout@v3

      - name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
        uses: actions/setup-dotnet@v3
        with:
          dotnet-version: ${{ matrix.dotnet-version }}

      - name: Install dependencies
        run: dotnet restore

      - name: Build
        run: dotnet publish --configuration Release --no-restore

      - name: Deploy
        uses: azure/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="66110304071616154b0203160a091f2610544854485756" rel="noreferrer noopener nofollow">[email protected]</a>
        with:
          app-name: example.com
          publish-profile: ${{ secrets.PUBLISH_PROFILE_PROD }}
          package: ./bin/Release/net6.0/publish

当此操作运行时,它会失败并出现以下错误:

Error: Failed to fetch credentials from Publish Profile. For more details on how to set publish profile credentials refer https://aka.ms/create-secrets-for-GitHub-workflows
Error: Deployment Failed, Error: Publish profile does not contain kudu URL

我做错了什么吗,我的服务器不接受这个,还是有其他问题?

(我在 github 操作页面上也有 opened a discussion about this)

最佳答案

那么,您使用 Godaddy 设置并将其发布到 Azure 上吗?是对的吗?我认为它无法工作,因为 webdeploy 设置仅适用于您现在使用的托管提供商。

关于azure - 如何将 WebPublish 与 Github 操作结合使用到 .NET Core 应用程序的 IIS 服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76705678/

相关文章:

azure - 将所有文件从 Amazon S3 存储桶复制到 Microsoft Azure 容器的最佳方法

reactjs - 如何指定端口在Azure Web应用程序中运行多个ReactJS应用程序?

azure - 将 Azure 存储计划与 Azure Web 应用结合使用

java - Play 框架和 Office 365 OAuth

Github Actions 徽章显示 "No status"

ruby-on-rails - 将 Ruby on Rails 应用程序部署到 Google App Engine

python - 需要 PIN - 无法将 Visual Studio 2015 中的 Python 代码部署到 Raspberry Pi 2 B 上

java - Tomcat 管理器脚本部署大型 war 不工作

python - Github Actions下构建作业时如何安装本地python包?

Github 工作流与私有(private) repo & 标签