0 people like it.
Like the snippet!
Authenticate to Azure with Service Principal
Authenticate to Azure with Service Principal
//https://docs.microsoft.com/en-us/dotnet/azure/dotnet-sdk-azure-authenticate?view=azure-dotnet#mgmt-auth
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
|
open Microsoft.Azure.Management.ResourceManager.Fluent
open Microsoft.Azure.Management.Fluent
let ClientId = "<Service Principal Application ID>"
let ServicePrincipalPassword = "<Service Principal Password>"
let AzureTenantId = "<tenant ID goes here>"
let AzureSubscriptionId = "<azure subscription ID goes here>"
let azureCredentials =
let servicePrincipalLoginInformation = Authentication.ServicePrincipalLoginInformation()
servicePrincipalLoginInformation.ClientId <- ClientId
servicePrincipalLoginInformation.ClientSecret <- ServicePrincipalPassword
Authentication.AzureCredentials(servicePrincipalLoginInformation, AzureTenantId, AzureEnvironment.AzureGlobalCloud)
let azure = Azure.Configure().Authenticate(azureCredentials).WithSubscription(AzureSubscriptionId)
let resourceGroups = azure.ResourceGroups.List()
resourceGroups
|> Seq.iter (fun x -> printfn "%s" x.Name)
|
namespace Microsoft
val ClientId : string
Full name: Script.ClientId
val ServicePrincipalPassword : string
Full name: Script.ServicePrincipalPassword
val AzureTenantId : string
Full name: Script.AzureTenantId
val AzureSubscriptionId : string
Full name: Script.AzureSubscriptionId
val azureCredentials : obj
Full name: Script.azureCredentials
val servicePrincipalLoginInformation : obj
val azure : obj
Full name: Script.azure
val resourceGroups : seq<obj>
Full name: Script.resourceGroups
Multiple items
module List
from Microsoft.FSharp.Collections
--------------------
type List<'T> =
| ( [] )
| ( :: ) of Head: 'T * Tail: 'T list
interface IEnumerable
interface IEnumerable<'T>
member GetSlice : startIndex:int option * endIndex:int option -> 'T list
member Head : 'T
member IsEmpty : bool
member Item : index:int -> 'T with get
member Length : int
member Tail : 'T list
static member Cons : head:'T * tail:'T list -> 'T list
static member Empty : 'T list
Full name: Microsoft.FSharp.Collections.List<_>
module Seq
from Microsoft.FSharp.Collections
val iter : action:('T -> unit) -> source:seq<'T> -> unit
Full name: Microsoft.FSharp.Collections.Seq.iter
val x : obj
val printfn : format:Printf.TextWriterFormat<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
More information