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.
- 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:
Replace{ "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 } }
repository_url
with the URL of your app's GitHub repository. - 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.
- 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" } } }
- You can Automate Deployment via GitHub Actions by
- Create a GitHub Actions workflow specifically for the Marketplace offer:
- Monitor new subscriptions.
- Deploy app code to the newly created App Service.
- 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 }}
- Create a GitHub Actions workflow specifically for the Marketplace offer:
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.