Skip to content
Merged

add ci #41934

Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sdk/provisioning/Azure.Provisioning/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Release History

## 1.0.0-beta.1 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes
81 changes: 81 additions & 0 deletions sdk/provisioning/Azure.Provisioning/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Azure Provisioning client library for .NET

Azure.Provisioning is a cloud development kit that allows you to declaritively specify your Azure infrastructure natively in dotnet.

## Getting started

### Install the package

Install the client library for .NET with [NuGet](https://www.nuget.org/ ):

```dotnetcli
dotnet add package Azure.Provisioning --prerelease
```

### Prerequisites

> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/).

### Authenticate the Client

## Key concepts

This library allows you to specify your infrastructure in a declarative style using dotnet. You can then use azd to deploy your infrastructure to Azure diretly without needing to write or maintain bicep or arm templates.

## Examples

Here is a simple example which creates a KeyVault.

First create your Infrastructure class.

```C# Snippet:SampleInfrastructure
public class SampleInfrastructure : Infrastructure
{
}
```

Next add your resources into your infrastructure and then Build.

```C# Snippet:KeyVaultOnly
// Create a new infrastructure
var infrastructure = new SampleInfrastructure();

// Add a new key vault
var keyVault = infrastructure.AddKeyVault();

// You can call Build to convert the infrastructure into bicep files
infrastructure.Build();
```

## Troubleshooting

- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues).
- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags.

## Next steps

## Contributing

For details on contributing to this repository, see the [contributing
guide][cg].

This project welcomes contributions and suggestions. Most contributions
require you to agree to a Contributor License Agreement (CLA) declaring
that you have the right to, and actually do, grant us the rights to use
your contribution. For details, visit <https://cla.microsoft.com>.

When you submit a pull request, a CLA-bot will automatically determine
whether you need to provide a CLA and decorate the PR appropriately
(for example, label, comment). Follow the instructions provided by the
bot. You'll only need to do this action once across all repositories
using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For
more information, see the [Code of Conduct FAQ][coc_faq] or contact
<[email protected]> with any other questions or comments.

<!-- LINKS -->
[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md
[coc]: https://opensource.microsoft.com/codeofconduct/
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/

209 changes: 209 additions & 0 deletions sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions sdk/provisioning/Azure.Provisioning/src/Construct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public abstract class Construct : IConstruct, IPersistableModel<Construct>
private List<IConstruct> _constructs;
private List<Output> _outputs;
private List<Resource> _existingResources;
private string _environmentName;
private string? _environmentName;

/// <inheritdoc/>
public string Name { get; }
Expand Down Expand Up @@ -75,7 +75,7 @@ protected Construct(IConstruct? scope, string name, ConstructScope constructScop
Subscription = scope is null ? this.GetOrCreateSubscription(subscriptionId) : scope.Subscription ?? scope.GetOrCreateSubscription(subscriptionId);
}

_environmentName = envName ?? Environment.GetEnvironmentVariable("AZURE_ENV_NAME") ?? throw new Exception("No environment variable found named 'AZURE_ENV_NAME'");
_environmentName = envName;
}

private string GetEnvironmentName()
Expand Down
2 changes: 1 addition & 1 deletion sdk/provisioning/Azure.Provisioning/src/Infrastructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class Infrastructure : Construct
/// <param name="subscriptionId">The subscription id to use. If not passed in will try to load from AZURE_SUBSCRIPTION_ID environment variable.</param>
/// <param name="envName">The environment name to use. If not passed in will try to load from AZURE_ENV_NAME environment variable.</param>
public Infrastructure(ConstructScope constructScope = ConstructScope.Subscription, Guid? tenantId = null, Guid? subscriptionId = null, string? envName = null)
: base(null, "default", constructScope, tenantId, subscriptionId, envName)
: base(null, "default", constructScope, tenantId, subscriptionId, envName ?? Environment.GetEnvironmentVariable("AZURE_ENV_NAME") ?? throw new Exception("No environment variable found named 'AZURE_ENV_NAME'"))
{
}

Expand Down
10 changes: 9 additions & 1 deletion sdk/provisioning/Azure.Provisioning/src/ResourceOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ public abstract class Resource<T> : Resource
/// </summary>
public T Properties { get; }

/// <inheritdoc/>
/// <summary>
/// Initializes a new instance of the <see cref="Resource{T}"/>.
/// </summary>
/// <param name="scope">The scope.</param>
/// <param name="parent">The parent.</param>
/// <param name="resourceName">The resouce name.</param>
/// <param name="resourceType">The resourceType.</param>
/// <param name="version">The version.</param>
/// <param name="properties">The properites.</param>
protected Resource(IConstruct scope, Resource? parent, string resourceName, ResourceType resourceType, string version, T properties)
: base(scope, parent, resourceName, resourceType, version, properties)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ResourceGroup(IConstruct scope, string? name = default, string version =
: base(scope, null, GetName(scope, name), ResourceType, version, ResourceManagerModelFactory.ResourceGroupData(
name: GetName(scope, name),
resourceType: ResourceType,
tags: new Dictionary<string, string> { { "azd-env-name", Environment.GetEnvironmentVariable("AZURE_ENV_NAME") ?? throw new Exception("No environment variable 'AZURE_ENV_NAME' was found") } },
tags: new Dictionary<string, string> { { "azd-env-name", scope.EnvironmentName } },
location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS))
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ resource resourceGroup_I6QNkoPsb 'Microsoft.Resources/resourceGroups@2023-07-01'
name: 'rg-TEST'
location: 'westus'
tags: {
azd-env-name: 'mnash-cdk'
azd-env-name: 'TEST'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resource resourceGroup_I6QNkoPsb 'Microsoft.Resources/resourceGroups@2023-07-01'
name: 'rg-TEST'
location: 'westus'
tags: {
azd-env-name: 'mnash-cdk'
azd-env-name: 'TEST'
key: 'value'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resource resourceGroup_I6QNkoPsb 'Microsoft.Resources/resourceGroups@2023-07-01'
name: 'rg-TEST'
location: 'westus'
tags: {
azd-env-name: 'mnash-cdk'
azd-env-name: 'TEST'
key: 'value'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ resource appServicePlan_kjMZSF1FP 'Microsoft.Web/serverfarms@2021-02-01' existin
name: 'appServicePlan_kjMZSF1FP'
}

resource webSite_vYvIqKCDk 'Microsoft.Web/sites@2021-02-01' = {
name: 'backEnd-mnash-cdk'
resource webSite_4pzZqR2OO 'Microsoft.Web/sites@2021-02-01' = {
name: 'backEnd-TEST'
location: 'westus'
identity: {
}
Expand All @@ -30,8 +30,8 @@ resource webSite_vYvIqKCDk 'Microsoft.Web/sites@2021-02-01' = {
}
}

resource applicationSettingsResource_Ys2FlARU8 'Microsoft.Web/sites/config@2021-02-01' = {
parent: webSite_vYvIqKCDk
resource applicationSettingsResource_Pfdqa0OdT 'Microsoft.Web/sites/config@2021-02-01' = {
parent: webSite_4pzZqR2OO
name: 'appsettings'
properties: {
SCM_DO_BUILD_DURING_DEPLOYMENT: 'False'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ resource keyVaultSecret_PrlUnEuAz 'Microsoft.KeyVault/vaults/secrets@2023-02-01'
}
}

resource sqlServer_GfC780gjO 'Microsoft.Sql/servers@2022-08-01-preview' = {
name: 'sqlserver-mnash-cdk'
resource sqlServer_zjdvvB2wl 'Microsoft.Sql/servers@2022-08-01-preview' = {
name: 'sqlserver-TEST'
location: 'westus'
properties: {
administratorLogin: 'sqladmin'
Expand All @@ -39,9 +39,9 @@ resource sqlServer_GfC780gjO 'Microsoft.Sql/servers@2022-08-01-preview' = {
}
}

resource sqlDatabase_06pzzL812 'Microsoft.Sql/servers/databases@2022-08-01-preview' = {
parent: sqlServer_GfC780gjO
name: 'db-mnash-cdk'
resource sqlDatabase_U7NzorRJT 'Microsoft.Sql/servers/databases@2022-08-01-preview' = {
parent: sqlServer_zjdvvB2wl
name: 'db-TEST'
location: 'westus'
properties: {
}
Expand All @@ -51,21 +51,21 @@ resource keyVaultSecret_NP8ELZpgb 'Microsoft.KeyVault/vaults/secrets@2023-02-01'
parent: keyVault_CRoMbemLF
name: 'connectionString'
properties: {
value: 'Server=${sqlServer_GfC780gjO.properties.fullyQualifiedDomainName}; Database=${sqlDatabase_06pzzL812.name}; User=appUser; Password=${appUserPassword}'
value: 'Server=${sqlServer_zjdvvB2wl.properties.fullyQualifiedDomainName}; Database=${sqlDatabase_U7NzorRJT.name}; User=appUser; Password=${appUserPassword}'
}
}

resource sqlFirewallRule_uT1qFq1g9 'Microsoft.Sql/servers/firewallRules@2020-11-01-preview' = {
parent: sqlServer_GfC780gjO
name: 'firewallRule-mnash-cdk'
resource sqlFirewallRule_eS4m8st65 'Microsoft.Sql/servers/firewallRules@2020-11-01-preview' = {
parent: sqlServer_zjdvvB2wl
name: 'firewallRule-TEST'
properties: {
startIpAddress: '0.0.0.1'
endIpAddress: '255.255.255.254'
}
}

resource deploymentScript_rue7c15EI 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
name: 'cliScript-mnash-cdk'
resource deploymentScript_3Zq2Pl8xa 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
name: 'cliScript-TEST'
location: 'westus'
kind: 'AzureCLI'
properties: {
Expand Down Expand Up @@ -93,11 +93,11 @@ SCRIPT_END
}
{
name: 'DBNAME'
value: '_p_.sqlDatabase_06pzzL812.name'
value: '_p_.sqlDatabase_U7NzorRJT.name'
}
{
name: 'DBSERVER'
value: '_p_.sqlServer_GfC780gjO.properties.fullyQualifiedDomainName'
value: '_p_.sqlServer_zjdvvB2wl.properties.fullyQualifiedDomainName'
}
{
name: 'SQLCMDPASSWORD'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ resource keyVault_CRoMbemLF 'Microsoft.KeyVault/vaults@2023-02-01' existing = {
name: 'keyVault_CRoMbemLF'
}

resource webSite_5n5qLSHlO 'Microsoft.Web/sites@2021-02-01' = {
name: 'frontEnd-mnash-cdk'
resource webSite_W5EweSXEq 'Microsoft.Web/sites@2021-02-01' = {
name: 'frontEnd-TEST'
location: 'westus'
identity: {
}
Expand All @@ -34,13 +34,13 @@ resource webSite_5n5qLSHlO 'Microsoft.Web/sites@2021-02-01' = {
}
}

resource applicationSettingsResource_0dS4jj7Cg 'Microsoft.Web/sites/config@2021-02-01' = {
parent: webSite_5n5qLSHlO
resource applicationSettingsResource_NslbdUwEt 'Microsoft.Web/sites/config@2021-02-01' = {
parent: webSite_W5EweSXEq
name: 'appsettings'
}

resource webSiteConfigLogs_PBLecfGMJ 'Microsoft.Web/sites/config@2021-02-01' = {
parent: webSite_5n5qLSHlO
resource webSiteConfigLogs_giqxapQs0 'Microsoft.Web/sites/config@2021-02-01' = {
parent: webSite_W5EweSXEq
name: 'logs'
properties: {
applicationLogs: {
Expand All @@ -64,4 +64,4 @@ resource webSiteConfigLogs_PBLecfGMJ 'Microsoft.Web/sites/config@2021-02-01' = {
}
}

output SERVICE_API_IDENTITY_PRINCIPAL_ID string = webSite_5n5qLSHlO.identity.principalId
output SERVICE_API_IDENTITY_PRINCIPAL_ID string = webSite_W5EweSXEq.identity.principalId
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resource resourceGroup_I6QNkoPsb 'Microsoft.Resources/resourceGroups@2023-07-01'
name: 'rg-TEST'
location: 'westus'
tags: {
azd-env-name: 'mnash-cdk'
azd-env-name: 'TEST'
key: 'value'
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

resource appServicePlan_rxltck14T 'Microsoft.Web/serverfarms@2021-02-01' existing = {
name: 'appServicePlan_rxltck14T'
resource appServicePlan_kjMZSF1FP 'Microsoft.Web/serverfarms@2021-02-01' existing = {
name: 'appServicePlan_kjMZSF1FP'
}

resource webSite_vYvIqKCDk 'Microsoft.Web/sites@2021-02-01' = {
name: 'backEnd-mnash-cdk'
resource webSite_4pzZqR2OO 'Microsoft.Web/sites@2021-02-01' = {
name: 'backEnd-TEST'
location: 'westus'
identity: {
}
kind: 'app,linux'
properties: {
serverFarmId: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-TEST/providers/Microsoft.Web/serverfarms/appServicePlan-mnash-cdk'
serverFarmId: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-TEST/providers/Microsoft.Web/serverfarms/appServicePlan-TEST'
siteConfig: {
linuxFxVersion: 'dotnetcore|6.0'
alwaysOn: true
Expand All @@ -30,8 +30,8 @@ resource webSite_vYvIqKCDk 'Microsoft.Web/sites@2021-02-01' = {
}
}

resource applicationSettingsResource_Ys2FlARU8 'Microsoft.Web/sites/config@2021-02-01' = {
parent: webSite_vYvIqKCDk
resource applicationSettingsResource_Pfdqa0OdT 'Microsoft.Web/sites/config@2021-02-01' = {
parent: webSite_4pzZqR2OO
name: 'appsettings'
properties: {
SCM_DO_BUILD_DURING_DEPLOYMENT: 'False'
Expand Down
Loading