-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change .net to AzureIdentityCredentialAdapter
- Loading branch information
Showing
20 changed files
with
245 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,8 @@ | |
*.factorypath | ||
*.project | ||
*.prefs | ||
.vscode/* | ||
.vscode/* | ||
terraform. | ||
.terraform | ||
terraform.tfstate* | ||
tf.plan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
resource "azurerm_resource_group" "rg" { | ||
name = "${var.basename}rg" | ||
location = var.location | ||
} | ||
|
||
resource "azurerm_servicebus_namespace" "sbns" { | ||
name = "${var.basename}sbns" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
sku = "Standard" | ||
} | ||
|
||
resource "azurerm_servicebus_topic" "sbtopic" { | ||
name = "topic1" | ||
resource_group_name = azurerm_resource_group.rg.name | ||
namespace_name = azurerm_servicebus_namespace.sbns.name | ||
} | ||
|
||
resource "azurerm_servicebus_subscription" "sbsub" { | ||
name = "sub1" | ||
resource_group_name = azurerm_resource_group.rg.name | ||
namespace_name = azurerm_servicebus_namespace.sbns.name | ||
topic_name = azurerm_servicebus_topic.sbtopic.name | ||
max_delivery_count = 1 | ||
} | ||
|
||
output "sb_connection_string" { | ||
value = azurerm_servicebus_namespace.sbns.default_primary_connection_string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#Set the terraform required version | ||
terraform { | ||
required_version = ">= 0.12.6" | ||
} | ||
|
||
# Configure the Azure Provider | ||
provider "azurerm" { | ||
# It is recommended to pin to a given version of the Provider | ||
version = "~>2" | ||
features {} | ||
} | ||
|
||
provider "random" { | ||
version = "~>2" | ||
} | ||
|
||
provider "null" { | ||
version = "~> 2.1" | ||
} | ||
|
||
# Data | ||
|
||
# Make client_id, tenant_id, subscription_id and object_id variables | ||
data "azurerm_client_config" "current" {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
variable "basename" { | ||
type = string | ||
description = "The base name for all resources" | ||
default = "azidexttest1" | ||
} | ||
|
||
variable "location" { | ||
type = string | ||
description = "Azure region where to create resources." | ||
default = "West US" | ||
} |
27 changes: 16 additions & 11 deletions
27
net/JonGallant.Azure.Identity.Extensions.Tests/Fluent/ResourceGroupTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
using DotNetEnv; | ||
using Microsoft.Azure.Management.ResourceManager.Fluent; | ||
using System; | ||
using Microsoft.Azure.Management.ResourceManager.Fluent; | ||
using DotNetEnv; | ||
using JonGallant.Azure.Identity.Extensions; | ||
using Xunit; | ||
using System.Threading.Tasks; | ||
using static DotNetEnv.Env; | ||
|
||
namespace JonGallant.Azure.Identity.Extensions.Tests.Fluent | ||
{ | ||
public class ResourceGroupTests | ||
{ | ||
[Fact] | ||
public void CreateAzCredsTest() | ||
public async Task CheckIfResourceGroupExistsTest() | ||
{ | ||
Env.Load("../../../.env"); | ||
Env.Load("../../../../../.env"); | ||
|
||
var creds = new AzureIdentityFluentCredentialAdapter( | ||
Environment.GetEnvironmentVariable("AZURE_TENANT_ID"), | ||
AzureEnvironment.AzureGlobalCloud); | ||
|
||
var name = Guid.NewGuid().ToString("n").Substring(0, 8); | ||
|
||
var creds = new DefaultAzureFluentCredential(Environment.GetEnvironmentVariable("AZURE_TENANT_ID"), AzureEnvironment.AzureGlobalCloud); | ||
|
||
var name = Environment.GetEnvironmentVariable("AZURE_RESOURCE_GROUP") + Guid.NewGuid().ToString("n").Substring(0, 8); | ||
|
||
var resourceGroup = Microsoft.Azure.Management.Fluent.Azure.Authenticate(creds). | ||
var resourceGroupExists = await Microsoft.Azure.Management.Fluent.Azure.Authenticate(creds). | ||
WithSubscription(Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID")). | ||
ResourceGroups.Define(name).WithRegion(Environment.GetEnvironmentVariable("AZURE_REGION")).Create(); | ||
ResourceGroups.ContainAsync(name); | ||
|
||
Assert.Equal(resourceGroup.Name, name); | ||
Assert.False(resourceGroupExists); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.