Hi All,
LIFE IS BEAUTIFUL 🙂 I hope we all are safe:) STAY SAFE, STAY HEALTHY 🙂 STAY HOME 🙂
UseCase: We have application where we need to use azure app client secret key and certificate for accessing Microsoft Graph APIs. So we decided to use the Azure Key Vault service to store azure app client secret key and certificate for security reasons. But then again to fetch the client secret key and certificate from Key Vault service we need to authenticate and here Managed Identity service come to picture 🙂
Since this article going to be big lets divide this articles into series. This is third article in this series: Creating simple Hello World .Net core application and deploy to Azure as a WebJob
If you didn’t got a chance to go through last two articles, kindly please have a look once –
- Azure – Connect to Key Vault from .Net Core application using Managed Identity – Part1 – Introduction to Azure Key Vault – In this article we are discussing Azure Key Vault
- Azure – Connect to Key Vault from .Net Core application using Managed Identity – Part2 – App Service – Creating App Service from Azure Portal – In this article we are discussing Azure App Service and Web jobs
So lets begin the fun 🙂
Take Away from this article: At the end of this article, we will got to know
- Creating .Net core console application
- Publishing .Net core console application to Azure as a WebJob
- Scheduling the WebJob
Prerequisites:
- Visual Studio 2019 with Azure development feature installed as shown in below Fig

- An Azure Account with Active subscription. We can create trial account as well
- Azure App Service – which we created in last article – Azure – Connect to Key Vault from .Net Core application using Managed Identity – Part2 – App Service – Creating App Service from Azure Portal
Step 1 – Creating .Net Core console application:
- Create a new project. Here I am using Visual Studio 2019 community edition as shown in below Fig

- Create “Console App (.NET Core)”

- Specify the project and solution name. Here we are giving the name – “KeyVaultDemo“

- Following is the .NET Core console application “KeyVaultDemo” created and make sure it get successfully build

- Please note here that we dont have “Settings.job” file yet in solution
Step 2 – Deploying .Net Core console application as a Web Job to Azure App Service:
- Right click on solution and click on “Publish” link as shown in below Fig

- Once we clicked on “Publish” link, “Publish” dialog will appear as shown in below Fig
- Select the option “Azure“

- In next step select the option “Azure Webjobs“

- Next we need to create either new Azure Webjob or need to select existing WebJob.
- We need to sign in the Visual Studio with appropriate account

- Once we signed in with appropriate account, on “Publish” dialog, we have listed the our App Service which we created as shown in below Fig

- Next click on “Finish” button as shown in above Fig, we will have all the summary as shown in below Fig.

- As soon as we publishing process successfully finished, there is a file called “Settings.job” added to the solution.
- Same is mentioned in output window as well
- Please observe the output window, detailed steps are mentioned in it. Which also gives an ideas what happens exactly when we publish our application to the Azure

- “Settings.job” file is used for scheduling our Webjob
- Please have look at following fig – “Settings.job” file contains some sample scheduling entries
- Here, we are scheduling our Webjob for every minute
- Please note the syntax for scheduling

- After publishing, from App Service page go to Webjobs where we will have our Webjob listed as shown in below Fig

- From WebJobs listings dashboard we will have various options available like “+Add” – for manually adding new WebJob, “Delete” – for manually deleting WebJob, “Refresh“
- If we select particular WebJob we will have “Run” option for running given WebJob
- We could see the properties by clicking on “Properties” option

- Once we ran the WebJob we get the message on the right top corner “Webjob is now running” as shown in below Fig

- We have scheduled the Webjob every minute as per the setting in “Settings.job” file
- Once Webjob executed successfully, we could see the logs as well by clicking on “Log” link as shown in below Fig

- Once we clicked on “Logs” link, we will be redirected to WebJob Details page as shown in below Fig
- On WebJobs Details page we have history or listing of all the executed WebJobs status.

- We could click the link under “TIMING” column as shown in above Fig to see the details of WebJob run or output of the job as shown in below Fig

- From “WebJob Run Details” page we have various options like “Toggle Output” button, “download” option to download the report in text file – it generate URL like https://knowledgejunction.scm.azurewebsites.net/vfs/data/jobs/triggered/KeyVaultDemo/202007310257000254/output_log.txt
- We have status message here and detailed output as shown in above Fig
Next Article: In next article, we will access the KeyVault keys to access the Microsoft GRAPH API and will discuss managed identity service
We have very good series on Azure, lots of discussion on Azure, please visit – https://knowledge-junction.com/?s=azure
Thanks for reading 🙂 If its worth at least reading once, kindly please like and share. SHARING IS CARING 🙂
Share in Teams:Enjoy the beautiful life 🙂 Have a FUN 🙂 HAVE A SAFE LIFE 🙂 TAKE CARE 🙂
You must log in to post a comment.