i dont want to deploy the whole web app or app service from a build/release pipeline. SFTP isnt a great option as there isnt a native powershell client.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@StingyJack, Thanks for the question! We are investigating and will update you shortly.
@StingyJack, You may try a similar approach as mentioned below and see if that helps:
siteConfig=azure site show $WEB_SITE_NAME -d --json
publishingUserName=echo $siteConfig| python -c "import json,sys;obj=json.load(sys.stdin);print obj['config']['publishingUserName'];"
publishingPassword=echo $siteConfig| python -c "import json,sys;obj=json.load(sys.stdin);print obj['config']['publishingPassword'];"
siteScmUrl=echo $siteConfig | python -c "import json,sys;obj=json.load(sys.stdin);print obj['site']['siteProperties']['properties']['RepositoryUri'];"
jobPath="zip/site/wwwroot/App_Data/jobs/$WEB_JOB_TYPE/$WEB_JOB_NAME"
fullUrl=$siteScmUrl$jobPath
curl -XPUT --data-binary @run.zip -u $publishingUserName:$publishingPassword $fullUrl
Checkout the Webjob REST APIs here https://github.com/projectkudu/kudu/wiki/WebJobs-API for some samples. See, the URL for more details.
@AjayKumar-MSFT - thanks but this does not run.
PS C:\Users\astanton> $WEB_SITE_NAME = "some website"
PS C:\Users\astanton> azure site show $WEB_SITE_NAME -d --json
azure : The term 'azure' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ azure site show $WEB_SITE_NAME -d --json
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (azure:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
@StingyJack, how exactly are you executing the cmds? If you choose to install and use the CLI locally, you need Azure CLI version 2.0 or later. To find the version, run az --version. If you need to install or upgrade, see Install the Azure CLI. If you use the previous version of the CLI (Azure classic CLI), you can continue to use it. However, we recommend updating to use the latest version of the Azure CLI for the best experience. If you use both CLIs, remember that azure is the classic CLI and that az is the most recent CLI.
You could refer this document for CLI samples for Azure App Service
@StingyJack, how exactly are you executing the cmds?
Powershell.
@StingyJack, could you please try the above cmds via Azure CLI as mentioned above and let us know how that goes. Also, checkout this discussion thread for the approach.
@StingyJack, Since we have not heard back from you we will now proceed to close this thread. If there are further questions regarding this matter, please tag me in your reply. We will gladly reopen the issue and continue the discussion.
After a bit of searching (too many things installed with "Azure command line" in the name), I'm actually trying to work through it now but I'm getting an error. It's really hard to read what it says (who picked these colors???).
@StingyJack, Thank you for posting back! Could you please send an email to AzCommunity[at]Microsoft[dot]com referencing this GitHub issue and we would like to work closer with you on this matter.
Sure.
My solution (with a little bit of PowerShell, but bash would also work):
dotnet publish src --configuration Release -o '../_zip/app_data/Jobs/Continuous/MyWebJob'
copy ./run.cmd './_zip/app_data/Jobs/Continuous/MyWebJob'
Compress-Archive -Path ./_zip/* -DestinationPath ./deploy.zip -Force
az webapp deployment source config-zip -g mywebjobapp-rg -n mywebjobapp --src ./deploy.zip
The file run.cmd
contains:
dotnet MyWebJob.dll %*
Working example here: https://github.com/DanielLarsenNZ/examples/blob/master/webjobs-eventhubs/deploy.ps1#L50
I ported @DanielLarsenNZ 's solution to bash and it worked. Here's an example.
Most helpful comment
I ported @DanielLarsenNZ 's solution to bash and it worked. Here's an example.