From the course: .NET Microservices for Azure Developers

Creating the service principal and configuring the repo - Azure Tutorial

From the course: .NET Microservices for Azure Developers

Creating the service principal and configuring the repo

- [Instructor] Remember that microservices should be deployed using automated processes such as CI/CD pipelines. In this course, we'll create those pipelines using GitHub actions. Before we create our first GitHub actions workflow, we need to retrieve the credentials for connecting to Azure. Specifically, we're going to create a service principal object to be used in GitHub. A service principal is an identity created for applications to access Azure resources. Okay, first, we need a resource group. To expedite this process, I've already created one named WPM, which stands for Wisdom Pet Medicine. You can see that it was created in the West US 3 region. Okay, let's go ahead and open up the terminal. Here in the terminal, I'm going to create a couple of variables, and then I'm going to use the Azure command line interface for executing the following command. ad, which stands for Active Directory, and then sp, which is service principal, and then create for role-based access control, and then the name of this service principal, and it's going to have contributor as the role and the scope is the resource group itself. And this is going to output a JSON document. So let's execute this. And after a little while, the command will show the JSON document. Please note that because I executed this command earlier during the video recording, it shows that an existing application was found. Okay, now let's copy this, since this is the JSON document that we need for connecting to Azure in GitHub. So let's open up the browser. Here in the repo, let's navigate to settings, and then let's expand secrets and variables and then navigate to actions, since we need to create a new secret. So let's click on that. And the name is AZURE_CREDENTIALS, and I'm going to paste the JSON document from the terminal. And finally, let's click on Add secret. And now with this secret, we'll be able to connect to Azure.

Contents