I'd like to fully automate my resource creation process. Unfortunately brand new subscriptions don't have a few resource providers registered by default. E.g. SQL. That's easily solved as described here: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-common-deployment-errors#noregisteredproviderfound
However this only outlines methods using either manually using the portal or using Powershell.
I'm looking for a solution using Microsoft.Azure.Management.ResourceManager.Fluent
It seems inconsistent that I wouldn't be able to do it using C#, but I can't seem to be able to find the functionality anywhere.
How to register resource providers for a new subscription using Azure fluent resource management?
We could use the following function in the Azure fluent resource management to registry providers.
I also do a demo for it.
Preparetion:
Registry Azure Active Directory application and assign Role
Then we can get the tenantId,clientId,clientSecretKey
Steps:
1.Create a C# console project and reference
Microsoft.Azure.Management.ResourceManager.Fluent
2.Get accesstoken
3. Initialize resourceManagementClient Object
4.Registry the resource provider
We also can list the unregistied providers
5.Check it from the Azure portal.
Code:
Packages.config:
Provider Auto registration feature is added in the upcoming release of Azure Management SDK (Fluent) v. 1.1.