Best way to deploy code and restore database in a managed Application on Azure MarketPlace

143 Views Asked by At

Our goal is publishing our offer to Azure MarketPlace. We created an ARM template for our infrastructure and had no issues with that.

Our main issue is how to deploy our code and DB schema through the purchase process.

Microsoft recommends Deployment Scripts so we made ours which contains, CLI commands to restore a .BACPAC sql file, app settings configurations and a CURL command for zip deployment via KUDU for the web application.

.BACPAC and zip package for code are in blob storage.

If we run our scripts in a custom ARM template deployment in Azure, they work fine !!

But when we run them through the marketplace purchase, they fail with no error logs.

Down below you can find our script commands.

"scriptContent": "
      az sql db import -s $sqlserver -n $sqldatabase -g $rg -p $sqlpassword -u $sqlusername --storage-key $sqlstoragekey --storage-key-type $storagekeytype --storage-uri $storageuri \r\n
      az webapp deployment user set --user-name $deploymentUser --password $deploymentPass \r\n
      az webapp config connection-string set --name $applicationName --resource-group $rg --settings DefaultConnection=\"Server=tcp:$sqlserver.database.windows.net,1433;Initial Catalog=$sqldatabase;Persist Security Info=False;User ID=$sqlusername;Password=$sqlpassword;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;\" --connection-string-type SQLAzure \r\n
      az webapp config appsettings set --name $applicationName --resource-group $rg --settings PortalUrl=\https://$applicationName.azurewebsites.net/\ \r\n
      az webapp config appsettings set --name $applicationName --resource-group $rg --settings AzureAd:Domain=\"$AADDomain\" \r\n
      az webapp config appsettings set --name $applicationName --resource-group $rg --settings AzureAd:ClientId=\"$AADClientId\" \r\n
      az webapp config appsettings set --name $applicationName --resource-group $rg --settings AzureAd:TenantId=\"$AADTenantId\" \r\n
      az webapp config appsettings set --name $applicationName --resource-group $rg --settings AzureAd:ClientSecret=\"$AADClientSecret\" \r\n
      az webapp restart --name $applicationName --resource-group $rg \r\n
      curl -X PUT -u $deploymentUser:$deploymentPass https://$applicationName.scm.azurewebsites.net/api/zipdeploy -H \"Content-Type: application/json\" -d \"{'packageUri':'$applicationUri$applicationStorageKey'}\" \r\n
      ",

In case our approach is wrong, any example, documentation and suggestions will be super helpful.

Feel free to ask for more information if any.

Thank you

0

There are 0 best solutions below