Deployed an Azure Function through YAML file for a .Net application but the azure portal is not showing the function. Please share correct YAML file or advise

Ashiqur Rahaman 0 Reputation points
2025-02-28T05:20:36.35+00:00

Deployed an Azure Function through YAML file for a .Net application but the azure portal is not showing the function APP. Please share correct YAML file or advise

==================DEPLOYMENT YAML FILE FOR AZURE FUNCTIONS=================

trigger:

  • AEDev

pool:

vmImage: 'windows-latest'

variables:

solution: '**/*.sln'

buildPlatform: 'Any CPU'

buildConfiguration: 'Release'

Azure Resource Manager connection created during pipeline creation

azureServiceConnectionId: '3712d8e6-d1ae-4179-a46e-148801b1f253'

Resource Group

resourceGroupName: 'jltechdev-rg'

Web app name

webAppName: 'jltech-dev-aeserviceP01'

Environment name

environmentName: 'jltech-dev-aeserviceP01'

stages:

  • stage: Build displayName: Build and Publish jobs:
    • job: Build displayName: Build Job pool: vmImage: 'windows-latest' steps:
      • task: UseDotNet@2 inputs: packageType: 'sdk' version: '8.x' installationPath: $(Agent.ToolsDirectory)/dotnet
      • task: NuGetToolInstaller@1
      • task: NuGetCommand@2 inputs: restoreSolution: '$(solution)' feedsToUse: config
      • task: VSBuild@1 inputs: solution: '$(solution)' #msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)"' #msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"' msbuildArgs: '/t:Publish /p:Configuration=Release /p:PublishDir=$(build.artifactstagingdirectory)\siteroot' platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' displayName: 'Build and Publish the project'
      • task: ArchiveFiles@2 inputs: rootFolderOrFile: '$(build.artifactstagingdirectory)\siteroot' includeRootFolder: false archiveType: 'zip' archiveFile: '$(build.artifactstagingdirectory)$(Build.BuildId).zip' replaceExistingArchive: true
      • task: PublishBuildArtifacts@1 inputs: PathtoPublish: '$(build.artifactStagingDirectory)' ArtifactName: 'drop'
  • stage: Deploy displayName: Deploy to Azure App Service jobs:
    • job: Deploy displayName: Deploy Job pool: vmImage: 'ubuntu-latest' steps:
      • download: current artifact: drop
      • task: AzureCLI@2 displayName: "Azure Web App Deploy" inputs: azureSubscription: $(azureServiceConnectionId) scriptType: pscore scriptLocation: inlineScript inlineScript: |
        az functionapp deployment source config-zip `
        
          --resource-group $(resourceGroupName) `
        
          --name $(webAppName) `
        
          --src $(Pipeline.Workspace)/drop/*.zip
        
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,094 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bodapati Harish 0 Reputation points Microsoft External Staff
    2025-03-06T12:10:19.23+00:00

    Your YAML deployment file seems mostly correct, but the issue could be related to one of the following common causes:

    • You’re using az functionapp deployment source config-zip with az CLI, but the package path might not be correct.
    • Make sure that your Function App is properly created in Azure as a Function App and not a regular Web App
    • If deploying to Linux, you need appType: functionAppLinux.

    Updated YAML for Azure Function Deployment

    • This corrects potential issues and improves reliability.
    trigger:
    
      - AEDev
    
    pool:
    
      vmImage: 'windows-latest'
    
    variables:
    
      solution: '**/*.sln'
    
      buildPlatform: 'Any CPU'
    
      buildConfiguration: 'Release'
    
      azureServiceConnectionId: '3712d8e6-d1ae-4179-a46e-148801b1f253'
    
      resourceGroupName: 'jltechdev-rg'
    
      functionAppName: 'jltech-dev-aeserviceP01'
    
    stages:
    
    - stage: Build
    
      displayName: "Build and Package"
    
      jobs:
    
      - job: Build
    
        displayName: "Build Job"
    
        pool:
    
          vmImage: 'windows-latest'
    
        steps:
    
        - task: UseDotNet@2
    
          inputs:
    
            packageType: 'sdk'
    
            version: '8.x'
    
            installationPath: $(Agent.ToolsDirectory)/dotnet
    
        - task: NuGetToolInstaller@1
    
        
    
        - task: NuGetCommand@2
    
          inputs:
    
            restoreSolution: '$(solution)'
    
            feedsToUse: 'config'
    
        - task: VSBuild@1
    
          inputs:
    
            solution: '$(solution)'
    
            msbuildArgs: '/t:Publish /p:Configuration=Release /p:PublishDir=$(build.artifactstagingdirectory)\publish_output'
    
            platform: '$(buildPlatform)'
    
            configuration: '$(buildConfiguration)'
    
            displayName: 'Build and Publish the project'
    
        - task: ArchiveFiles@2
    
          displayName: "Archive files"
    
          inputs:
    
            rootFolderOrFile: '$(build.artifactstagingdirectory)\publish_output'
    
            includeRootFolder: false
    
            archiveType: 'zip'
    
            archiveFile: '$(build.artifactstagingdirectory)/$(Build.BuildId).zip'
    
            replaceExistingArchive: true
    
        - task: PublishBuildArtifacts@1
    
          inputs:
    
            PathtoPublish: '$(build.artifactstagingdirectory)'
    
            ArtifactName: 'drop'
    
    - stage: Deploy
    
      displayName: "Deploy to Azure Function"
    
      jobs:
    
      - job: Deploy
    
        displayName: "Deploy Job"
    
        pool:
    
          vmImage: 'ubuntu-latest'
    
        steps:
    
        - download: current
    
          artifact: drop
    
        - task: AzureFunctionApp@2
    
          displayName: "Deploy to Azure Function App"
    
          inputs:
    
            azureSubscription: $(azureServiceConnectionId)
    
            appType: functionApp
    
            appName: $(functionAppName)
    
            package: $(Pipeline.Workspace)/drop/*.zip
    
            deploymentMethod: 'auto'
    
    

    Hope this helps!

    If you found this answer helpful, please click Accept Answer and consider upvoting it /click yes.

    accept

    If you have any further questions, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.