2
votes

We're trying to deploy a prebuilt bot artefact into tenants via ARM deployments kicked off with REST APIs. We're struggling to replicate the actions of a gui based deployment from vs code / visual studio given that all the docs use the az cli. A manual deploy ends up with an app that includes dlls at the top level whereas our current route doesn't include the built dlls.

Our pipeline for producing our bot artifact is:

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: AzureCLI@2
  inputs:
    azureSubscription: 'GoSmarter Azure Service Connection'
    scriptType: 'ps'
    scriptLocation: 'scriptPath'
    scriptPath: 'az-Prepare.ps1'

Where az-Prepare.ps1 includes az bot prepare-deploy --lang Csharp --code-dir $codeDirectory --proj-file-path $projectFileName to produce the zip of the bot app so that we can put it into blob storage for use in the ARM template.

We then use an MSDeploy ARM resource to deploy this zip file as part of a bigger provisioning step.

    {
      "name": "MSDeploy",
      "type": "extensions",
      "location": "[variables('resourcesLocation')]",
      "apiVersion": "2015-08-01",
      "dependsOn": [
        "[resourceId('Microsoft.Web/sites', variables('webAppName'))]"
      ],
      "tags": {
        "displayName": "deployArchive"
      },
      "properties": {
        "packageUri": "[concat(variables('source'),'qnabotarchive.zip',parameters('SasToken'))]",
        "dbType": "None",
        "connectionString": ""
      }
    }

We tried setting the Kudu App Setting for triggering builds to true but this doesn't seem to apply to MSDeploy provided zips so doesn't do a promotion of the dlls.

        {
          "name": "SCM_DO_BUILD_DURING_DEPLOYMENT",
          "value": "true"
        }

Does anyone know what the right way is to configure the build, the app and/or the ARM template for the bot deployment to provide the dlls at the top level?

1
I am not sure, why would you use two tasks for publishing projects? Under normal circumstances, isn't the bot project and the web project in the same solution, will the bot project become a bot.dll file when it is compiled and released?Jason Pan
@JasonPan ah, we do a test between the steps I just shortened for brevity, but your thought is we can just do a standard c# build and deploy and ignore the bot deployment process? docs.microsoft.com/en-us/azure/bot-service/…Steph Locke
Yes, I think so. I think it will be the best way for you.Jason Pan
Do you meaning put the built dlls at the project root folder, when you say provide the dlls at the top level? How did you create the deployment zip file?Levi Lu-MSFT
@LeviLu-MSFT we've been following along with this guide where possible docs.microsoft.com/en-us/azure/bot-service/… However, we're balancing it with the need to support multi-tenant deployments so we can't do things from the az cli because we can't provide the on behalf of access token we receive. Using the az bot prepare-deploy command doesn't make a fully deployable zip via msdeploy in arm. The az webapp deployment source command in the docs uses kudu which does it's own build and puts the dlls in the top level dirSteph Locke

1 Answers

2
votes

In the end, we opted for using dotnet core commands to build the bot solution.

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '$(project)'
    arguments: '--configuration $(BuildConfiguration) -p:langversion=latest'
  displayName: "Build solution"

- task: DotNetCoreCLI@2
  displayName: "Publish Build Output"
  inputs:
    command: 'publish'
    publishWebProjects: true
    arguments: '--configuration $(BuildConfiguration) -p:langversion=latest --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: false

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/QnABot/*'
    includeRootFolder: true
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/Chatbots/qnabotarchive.zip'
    replaceExistingArchive: true