You can deploy Farmer templates in a number of ways, depending on how you would prefer to work with ARM templates and tooling.
If you don’t use ARM templates today, or don’t need to edit them directly, you can opt to do away with them completely. You’ll create Farmer applications which use a simple F# SDK to interact with Azure; Farmer will create ARM templates in the background for you transparently, so you’ll never see or interact with them.
In such a case, you can opt to deploy directly through Farmer. This mode provides an F# wrapper around the Azure CLI which captures your credentials during the deployment process.
If you’re looking to stay within F# and e.g. respond to outcomes from the deployment such as using deployment outputs, this is an excellent option because Farmer is just a dotnet application and the deployment call is a simple function call.
Another benefit of this is because Farmer is a simple .NET Standard library, you can use it natively within .NET build tools such as FAKE or CAKE.
Farmer can also optionally do more for you by handling the entire deployment process, including deployment of your application artifacts.
Watch this short video to see more!
If you already use ARM templates, you’ll probably already have a strategy for working with templates and deploying them to Azure, such as PowerShell, the Azure CLI or a build system such as Azure DevOps or Octopus Deploy. In such a case, you may want to use Farmer to generate, but not deploy, your ARM templates.
If you want to retain fine-grained control over ARM templates, you can use Farmer to create a one-off task to rapidly generate an ARM template which you then take ownership of. In this case, Farmer itself won’t be a part of your build / deploy chain, which will remain the same as today - you’ll use Farmer just as an edit-time task to create an ARM template itself which you will then manually modify.
The choice is yours.
If you’re trying to deploy to Azure in an automated fashion, you may need to create a Service Principal account that has permissions in Azure to deploy ARM templates on your behalf.
The Azure CLI provides a simple way to create one using the az ad sp command:
az ad sp create-for-rbac --name farmer-deploy
This will provide output similar to the following:
The mapping from these fields to the credentials used in Farmer’s
authenticate function are:
You should store these credentials in a secure store, such as your CI/CD service or e.g. Azure KeyVault and should avoid committing them into source control.