Skip to content

Commit

Permalink
Use globally unique name for top level resources (#42613)
Browse files Browse the repository at this point in the history
* Use globally unique name for top level resources

* api
  • Loading branch information
JoshLove-msft authored Mar 11, 2024
1 parent 3fb4376 commit 00d6578
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public partial class AppConfigurationStore : Azure.Provisioning.Resource<Azure.R
{
public AppConfigurationStore(Azure.Provisioning.IConstruct scope, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "store", string version = "2023-03-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func<string, Azure.ResourceManager.AppConfiguration.AppConfigurationStoreData>)) { }
public static Azure.Provisioning.AppConfiguration.AppConfigurationStore FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; }
protected override string GetAzureName(Azure.Provisioning.IConstruct scope, string resourceName) { throw null; }
}
}
namespace Azure.Provisioning.AppService
Expand Down Expand Up @@ -204,6 +205,7 @@ public partial class CognitiveServicesAccount : Azure.Provisioning.Resource<Azur
{
public CognitiveServicesAccount(Azure.Provisioning.IConstruct scope, string? kind = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku? sku = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "cs", string version = "2023-05-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func<string, Azure.ResourceManager.CognitiveServices.CognitiveServicesAccountData>)) { }
public static Azure.Provisioning.CognitiveServices.CognitiveServicesAccount FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; }
protected override string GetAzureName(Azure.Provisioning.IConstruct scope, string resourceName) { throw null; }
}
public partial class CognitiveServicesAccountDeployment : Azure.Provisioning.Resource<Azure.ResourceManager.CognitiveServices.CognitiveServicesAccountDeploymentData>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public partial class AppConfigurationStore : Azure.Provisioning.Resource<Azure.R
{
public AppConfigurationStore(Azure.Provisioning.IConstruct scope, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "store", string version = "2023-03-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func<string, Azure.ResourceManager.AppConfiguration.AppConfigurationStoreData>)) { }
public static Azure.Provisioning.AppConfiguration.AppConfigurationStore FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; }
protected override string GetAzureName(Azure.Provisioning.IConstruct scope, string resourceName) { throw null; }
}
}
namespace Azure.Provisioning.AppService
Expand Down Expand Up @@ -204,6 +205,7 @@ public partial class CognitiveServicesAccount : Azure.Provisioning.Resource<Azur
{
public CognitiveServicesAccount(Azure.Provisioning.IConstruct scope, string? kind = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku? sku = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "cs", string version = "2023-05-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func<string, Azure.ResourceManager.CognitiveServices.CognitiveServicesAccountData>)) { }
public static Azure.Provisioning.CognitiveServices.CognitiveServicesAccount FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; }
protected override string GetAzureName(Azure.Provisioning.IConstruct scope, string resourceName) { throw null; }
}
public partial class CognitiveServicesAccountDeployment : Azure.Provisioning.Resource<Azure.ResourceManager.CognitiveServices.CognitiveServicesAccountDeploymentData>
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/provisioning/Azure.Provisioning/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/provisioning/Azure.Provisioning",
"Tag": "net/provisioning/Azure.Provisioning_d2660e3b79"
"Tag": "net/provisioning/Azure.Provisioning_2e6e26284c"
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public AppConfigurationStore(IConstruct scope, ResourceGroup? parent = null, str
location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS,
skuName: "free"))
{
AssignProperty(data => data.Name, GetAzureName(scope, name));
AddOutput($"{Name}_endpoint", store => store.Endpoint);
}

Expand All @@ -49,5 +50,8 @@ private AppConfigurationStore(IConstruct scope, ResourceGroup? parent = null, st
/// <returns>The KeyVault instance.</returns>
public static AppConfigurationStore FromExisting(IConstruct scope, string name, ResourceGroup? parent = null)
=> new AppConfigurationStore(scope, parent, name, isExisting: true);

/// <inheritdoc/>
protected override string GetAzureName(IConstruct scope, string resourceName) => GetGloballyUniqueName(resourceName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public CognitiveServicesAccount(
kind: kind ?? "OpenAI",
properties: new CognitiveServicesAccountProperties()))
{
AssignProperty(data => data.Name, GetAzureName(scope, name));
}

private CognitiveServicesAccount(
Expand All @@ -65,5 +66,8 @@ private CognitiveServicesAccount(
/// <returns>The KeyVault instance.</returns>
public static CognitiveServicesAccount FromExisting(IConstruct scope, string name, ResourceGroup? parent = null)
=> new CognitiveServicesAccount(scope, parent: parent, name: name, isExisting: true);

/// <inheritdoc/>
protected override string GetAzureName(IConstruct scope, string resourceName) => GetGloballyUniqueName(resourceName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ module rg_TEST_module './resources/rg_TEST_module/rg_TEST_module.bicep' = {
scope: resourceGroup_I6QNkoPsb
}

output appConfigurationStore_sgecYnln3_endpoint string = rg_TEST_module.outputs.appConfigurationStore_sgecYnln3_endpoint
output appConfigurationStore_4WdTZ5u6X_endpoint string = rg_TEST_module.outputs.appConfigurationStore_4WdTZ5u6X_endpoint
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

resource appConfigurationStore_sgecYnln3 'Microsoft.AppConfiguration/configurationStores@2023-03-01' = {
name: 'store-TEST'
resource appConfigurationStore_4WdTZ5u6X 'Microsoft.AppConfiguration/configurationStores@2023-03-01' = {
name: toLower(take(concat('store', uniqueString(resourceGroup().id)), 24))
location: 'westus'
sku: {
name: 'free'
Expand All @@ -9,4 +9,4 @@ resource appConfigurationStore_sgecYnln3 'Microsoft.AppConfiguration/configurati
}
}

output appConfigurationStore_sgecYnln3_endpoint string = appConfigurationStore_sgecYnln3.properties.endpoint
output appConfigurationStore_4WdTZ5u6X_endpoint string = appConfigurationStore_4WdTZ5u6X.properties.endpoint
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ param location string = resourceGroup().location
param publicNetworkAccess string = 'Enabled'


resource cognitiveServicesAccount_ZfMvJY5Po 'Microsoft.CognitiveServices/accounts@2023-05-01' = {
name: 'cs-TEST'
resource cognitiveServicesAccount_cNLMqn7X3 'Microsoft.CognitiveServices/accounts@2023-05-01' = {
name: toLower(take(concat('cs', uniqueString(resourceGroup().id)), 24))
location: location
kind: 'OpenAI'
sku: {
Expand All @@ -19,8 +19,8 @@ resource cognitiveServicesAccount_ZfMvJY5Po 'Microsoft.CognitiveServices/account
}
}

resource cognitiveServicesAccountDeployment_JeeW2XLVR 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = {
parent: cognitiveServicesAccount_ZfMvJY5Po
resource cognitiveServicesAccountDeployment_WYhBFVWTN 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = {
parent: cognitiveServicesAccount_cNLMqn7X3
name: 'cs'
sku: {
name: 'S0'
Expand All @@ -34,5 +34,5 @@ resource cognitiveServicesAccountDeployment_JeeW2XLVR 'Microsoft.CognitiveServic
}
}

output endpoint string = 'Endpoint=${cognitiveServicesAccount_ZfMvJY5Po.properties.endpoint}'
output expression string = uniqueString(cognitiveServicesAccount_ZfMvJY5Po.properties.endpoint)
output endpoint string = 'Endpoint=${cognitiveServicesAccount_cNLMqn7X3.properties.endpoint}'
output expression string = uniqueString(cognitiveServicesAccount_cNLMqn7X3.properties.endpoint)

0 comments on commit 00d6578

Please sign in to comment.