I've been playing with PowerShell this week creating a new Azure environment for our deployment, the final part of this calls for a WebJob written in C# to accept a message from a queue and create a new database and create the structure as required.
I was wondering if anyone here has done this before, I have found the azure management libraries for .NET which have examples of database creation but I'm stuck on the authorisation as this will be done from a back end process?
Is there anyway I can create a trust in my Azure environment to allow my WebJob to connect Azure (although the app is running in the same subscription) and create a new database?
At this time I don't really have any code more like ideas which is why I'm asking for help :)
I am assuming I would use something like this to authenticate?
var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(
"clientid",
"clientsecret",
"tenantid",
AzureEnvironment.AzureGlobalCloud);
// Connect to Azure
var azure = Azure.Authenticate(credentials).WithDefaultSubscription();
I assume I may need to do something in Azure itself to trust the WebJob to have the access to create a new Azure database but this is the part I'm not sure about.
From PowerShell I've done the authentication by letting PS bring up the Microsoft Live Login Screen but this is not practical for a WebJob with no UI.
Hope this makes sense, and someone can shed some light on it for me?