How to Automate Deployment of Web App Code to App Service After Subscription in Azure Marketplace?

Ariel Morais 20 Reputation points
2024-12-13T12:37:33.92+00:00

Hi, I have created a web app and successfully deployed it using local Git. My goal is to sell this app via the Azure Marketplace, and I configured the offer so that an App Plan and App Service are created upon subscription.

Here’s the situation:

  1. The offer is live, and I was able to purchase it using the same account I used to publish the app. In this case, I could find the Managed Resource Group and deploy the app code manually via the Deployment Center using local Git.
  2. However, when I purchased the app using a separate customer account, the code was not deployed. The customer can access the Deployment Center but would not have the code to deploy it themselves.
  3. From my publisher account, I couldn’t locate the Managed Resource Group associated with the customer's purchase to deploy the code either.

My question is:

  • Where should I specify the source code or deployment configuration to ensure the application code is automatically deployed to the App Service after the resources are created during subscription?
  • Should this configuration be part of the ARM template, or is there another step I’m missing?

Any guidance or best practices would be greatly appreciated.

Thank you!

Azure Managed Applications
Azure Managed Applications
An Azure service that enables managed service providers, independent software vendors, and enterprise IT teams to deliver turnkey solutions through the Azure Marketplace or service catalog.
156 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,097 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sina Salam 14,626 Reputation points
    2024-12-15T02:37:28.49+00:00

    Hello Ariel Morais,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you would like to Automate Deployment of Web App Code to App Service After Subscription in Azure Marketplace and major challenges here are:

    • Customers cannot access or deploy the app code automatically after subscription.
    • The publisher account cannot locate the customer's Managed Resource Group.
    • There is a need for a solution that ensures the app code is deployed automatically after resource creation via Azure Marketplace.

    NOTE: This is unique requirements of Azure Marketplace offers not suited for a standard App Service setup but rather the integrated with Azure Marketplace best solution to ensure seamless automatic deployment of your web app via Azure Marketplace.

    1. Modify the ARM Template for Automation by: Using the ARM template to configure a post-deployment script or source control integration. Example of the snippet to deploy the app code automatically:
         {
           "type": "Microsoft.Web/sites/extensions",
           "apiVersion": "2021-02-01",
           "name": "siteextensions/Kudu",
           "dependsOn": [
             "[resourceId('Microsoft.Web/sites', parameters('appName'))]"
           ],
           "properties": {
             "repository_url": "https://github.com/your-repo/your-app",
             "branch": "main",
             "isManualIntegration": true
           }
         }
      
      Replace repository_url with the URL of your app's GitHub repository.
    2. Azure Marketplace offers typically help to create Managed Applications with a Managed Resource Group that belongs to the customer by leverage Azure Managed Applications you can use the Azure Resource Manager lockbox feature to enable your publisher account to access the customer’s Managed Resource Group. Then, add deployment configurations to the mainTemplate.json of the Managed Application.
    3. You can use a Custom Script Extension by adding a custom script extension to the ARM template to pull the app code from your repository and deploy it automatically. For an example:
         {
           "type": "Microsoft.Compute/virtualMachines/extensions",
           "apiVersion": "2021-03-01",
           "name": "CustomScriptExtension",
           "location": "[resourceGroup().location]",
           "dependsOn": [
             "[resourceId('Microsoft.Web/sites', parameters('appName'))]"
           ],
           "properties": {
             "publisher": "Microsoft.Azure.Extensions",
             "type": "CustomScript",
             "typeHandlerVersion": "2.1",
             "autoUpgradeMinorVersion": true,
             "settings": {
               "fileUris": ["https://path-to-your-script/deploy.sh"],
               "commandToExecute": "bash deploy.sh"
             }
           }
         }
      
    4. You can Automate Deployment via GitHub Actions by
      1. Create a GitHub Actions workflow specifically for the Marketplace offer:
        1. Monitor new subscriptions.
        2. Deploy app code to the newly created App Service.
        3. An example GitHub Actions YAML:
                   name: Deploy to Azure App Service
                   on:
                     push:
                       branches:
                         - main
                   jobs:
                     build-and-deploy:
                       runs-on: ubuntu-latest
                       steps:
                         - uses: actions/checkout@v2
                         - name: Login to Azure
                           uses: azure/login@v1
                           with:
                             creds: ${{ secrets.AZURE_CREDENTIALS }}
                         - name: Deploy to Azure App Service
                           uses: azure/webapps-deploy@v2
                           with:
                             app-name: 'your-app-service-name'
                             slot-name: 'production'
                             publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }}
          

    Check if this answers your Questions:

    Where to specify source code or deployment configuration?

    Specify the configuration in the ARM template using siteConfig, source control settings, or a custom script extension.

    Should this configuration be part of the ARM template?

    Yes, the ARM template should include all deployment configurations to ensure automation.

    How to automate deployment of web app code?

    Use CI/CD pipelines, ARM template configurations, or custom scripts as outlined above.

    Any guidance or best practices?

    Follow best practices like leveraging Managed Applications, setting up deployment slots, and monitoring subscriptions:

    • Notify the customer that the app is ready to use after deployment by Automate Customer Notifications
    • Use Azure Event Grid to monitor subscription events and trigger workflows to Monitor Marketplace Subscriptions.
    • Provide clear guidance on managing and updating the deployed app by documentation for Customers.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.


0 additional answers

Sort by: Most helpful

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.