I am working on macOS with an external text editor (NOT VisualStudio). I have an asp.net project that I push to my app service using
git push azure main:master
the remote is configured as such https://$name:[email protected]:443/name.git
when I go to the web jobs section in the app service to add a web job, I get the error message:
I want to continue using my source control push method while developing... however I would also like to add a csharp console webjob . I have followed the tutorial here (A) https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-get-started, and have a functoining console app that consumes a message from a queue.
How can I push this extra console app to my Kudu instance? I read here that there is a 'hidden' structure not in the main doucmentation (A) I linked above for the tutorial: https://github.com/projectkudu/kudu/wiki/WebJobs.
Do I have to manually zip the result of dotnet publish -c Release
to some Kudu folder? Or is there a more elegant way by somehow including this project inside my git repo that I push normally... or using an az cli
tool to push the webjob to the app?
CodePudding user response:
I created the Web Job and tried to Add it from App service, got the below error.
Using Azure CLI, we can deploy our Web Jobs to App Service
Web Jobs need to be deployed to the below folder in KUDU Console, Create a folder with Web Job Name in the below path
app_data\jobs\triggered\NewFolder
- Zip all the contents of the Web Job into one folder.
wwwroot
folder path will be read-only mode, we need to enable it by setting WEBSITE_RUN_FROM_PACKAGE to 1- Set the
WEBSITE_RUN_FROM_PACKAGE
to 1 in WebApp => Configuration => Application Settings or run the CLI command to set it.
az webapp config appsettings set --resource-group YourRGName --name AppServiceName --settings WEBSITE_RUN_FROM_PACKAGE="1"
- Zip deploy Web Job to the existing Azure App service
az webapp deployment source config-zip --resource-group YourRGName --name YourAppService --src YourZipFilePath
- We can directly drag and drop the Web Jobs Zip folder from the KUDU Console as well
- We can deploy our Web Jobs in many ways. We can FTP / Use Build Pipelines/ Zip Deploy.
CodePudding user response:
Found a way to push directly using az cli
az webapp deploy --name $APP_NAME -g $RG \
--src-path program.py \
--type static \
--target-path /home/site/Jobs/continuous/Job$RANDOM/program.py
for larger programs in .net I just dumped the project on Kudu, unzipped, and rebuilt (I'm on a mac m1 so can't build against x64 without some hoops, this was easier workaround)
# on my machine
az webapp deploy --name $APP_NAME -g $RG \
--src-path path_to_dotnet_project.zip \
--type static \
--target-path /home/site/Jobs/continuous/Job5/myproject.zip
then on the app service (using kudu cmd/powershell)
cd /home/site/Jobs/continuous/Job5
unzip myproject.zip
dotnet build -c Release
cp bin/release/net6.0/* /home/site/Jobs/continuous/MyNewJob
#job in MyNewJob automatically starts since this is in the 'continuous' folder