Reputation: 6271
Tasked with creating an automated Azure deploy and swap 'tool,' I would like use C# and Azure Resource Manager and add it to a WebAPI Server. However, documentation seems limited.
For example, the following is the link for ARMs BeginSwapSlotWithProduction()
Googling that method returns only 7 results!
I see Azure PowerShell cmdlets very well documented.
And so is Azure Resource Manager with Templates. <- Not type safe.
I have considered using Powershell inline in C# such as documented here. But seems I am fighting the system.
Attempting to keep this question from being Opinion Based. Are there other alternatives I have not mentioned here.
Looking for a well documented, strongly typed way to interact with Azure basically.
Upvotes: 1
Views: 232
Reputation: 24529
If you want to swap or deploy WebApp, you could use the Microsoft.Azure.Management.Fluent and Microsoft.Azure.Management.ResourceManager.Fluent. We also could get more demo code from the github Azure SDK. About how to get the credential file you could refer to Authentication in Azure Management Libraries for .NET.
The following is the demo code.
var credentials = SdkContext.AzureCredentialsFactory.FromFile(@"Credential file path");
var azure = Azure
.Configure()
.WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
.Authenticate(credentials)
.WithDefaultSubscription();
//create WebApp
var webApp = azure.WebApps.Define(appName)
.WithRegion(Region.USWest)
.WithNewResourceGroup(rgName)
.WithNewFreeAppServicePlan()
.Create();
//Deploy WebApp
webApp .Deploy().WithPackageUri("packageUri");
//get WebApp
var webApp = azure.WebApps.GetByResourceGroup("rgName", "appName");
//swap WebApp
webApp.Swap("slotName");
Upvotes: 1