Skip to content

Commit f3ba71a

Browse files
Sql mgmt track 2 library (Azure#25550)
1 parent ff247cf commit f3ba71a

File tree

1,732 files changed

+3777848
-235895
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,732 files changed

+3777848
-235895
lines changed

.vscode/cspell.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@
187187
"Droppeded",
188188
"CIAS",
189189
"Vcores",
190-
"Unrestorable"
190+
"Unrestorable",
191+
"Stdev",
192+
"Ntext",
193+
"Nvarchar",
194+
"Stdev"
191195
]
192196
},
193197
{

sdk/sqlmanagement/Azure.ResourceManager.Sql/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release History
22

3-
## 1.0.0-preview.1 (Unreleased)
3+
## 1.0.0-beta.1 (2021-12-03)
44

55
This package follows the [Azure SDK Design Guidelines for .NET](https://azure.github.io/azure-sdk/dotnet_introduction.html) which provide a number of core capabilities that are shared amongst all Azure SDKs, including the intuitive Azure Identity library, an HTTP Pipeline with custom policies, error-handling, distributed tracing, and much more.
66

sdk/sqlmanagement/Azure.ResourceManager.Sql/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur
99
Install the Azure SQL management library for .NET with [NuGet](https://www.nuget.org/):
1010

1111
```PowerShell
12-
Install-Package Azure.ResourceManager.Sql -Version 1.0.0-preview.1
12+
Install-Package Azure.ResourceManager.Sql -Version 1.0.0-beta.1
1313
```
1414

1515
### Prerequisites

sdk/sqlmanagement/Azure.ResourceManager.Sql/api/Azure.ResourceManager.Sql.netstandard2.0.cs

Lines changed: 7297 additions & 3526 deletions
Large diffs are not rendered by default.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
page_type: sample
3+
languages:
4+
- csharp
5+
products:
6+
- azure
7+
- azure-resource-manager
8+
name: Azure.ResourceManager.Sql samples for .NET
9+
description: Samples for the Azure.ResourceManager.Sql client library
10+
---
11+
12+
# Azure.ResourceManager.Resources Samples
13+
14+
- [Managing Managed Instance](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Sample1_ManagingManagedInstance.md)
15+
- [Managing Managed Databases](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Sample2_ManagingManagedDatabases.md)
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Example: Managing the ManagedInstance
2+
3+
>Note: Before getting started with the samples, go through the [prerequisites](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/resourcemanager/Azure.ResourceManager#prerequisites).
4+
5+
Namespaces for this example:
6+
```C# Snippet:Manage_ManagedInstance_Namespaces
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Threading.Tasks;
10+
using Azure.Core;
11+
using Azure.Identity;
12+
using Azure.ResourceManager.Network;
13+
using Azure.ResourceManager.Network.Models;
14+
using Azure.ResourceManager.Resources;
15+
using Azure.ResourceManager.Resources.Models;
16+
using Azure.ResourceManager.Sql.Models;
17+
using NUnit.Framework;
18+
```
19+
20+
When you first create your ARM client, choose the subscription you're going to work in. You can use the `GetDefaultSubscription`/`GetDefaultSubscriptionAsync` methods to return the default subscription configured for your user:
21+
22+
```C# Snippet:Readme_DefaultSubscription
23+
ArmClient armClient = new ArmClient(new DefaultAzureCredential());
24+
Subscription subscription = armClient.GetDefaultSubscription();
25+
```
26+
27+
This is a scoped operations object, and any operations you perform will be done under that subscription. From this object, you have access to all children via collection objects. Or you can access individual children by ID.
28+
29+
```C# Snippet:Readme_GetResourceGroupCollection
30+
ArmClient armClient = new ArmClient(new DefaultAzureCredential());
31+
Subscription subscription = await armClient.GetDefaultSubscriptionAsync();
32+
ResourceGroupCollection rgCollection = subscription.GetResourceGroups();
33+
// With the collection, we can create a new resource group with an specific name
34+
string rgName = "myRgName";
35+
Location location = Location.WestUS2;
36+
ResourceGroupCreateOrUpdateOperation lro = await rgCollection.CreateOrUpdateAsync(rgName, new ResourceGroupData(location));
37+
ResourceGroup resourceGroup = lro.Value;
38+
```
39+
40+
Now that we have the resource group created, we can manage the managed instance inside this resource group.
41+
42+
***Create a managed instance***
43+
44+
```C# Snippet:Managing_Sql_CreateAManagedInstance
45+
//1. create NetworkSecurityGroup
46+
NetworkSecurityGroupData networkSecurityGroupData = new NetworkSecurityGroupData()
47+
{
48+
Location = Location.WestUS2,
49+
};
50+
string networkSecurityGroupName = "myNetworkSecurityGroup";
51+
var networkSecurityGroup = await resourceGroup.GetNetworkSecurityGroups().CreateOrUpdateAsync(networkSecurityGroupName, networkSecurityGroupData);
52+
53+
//2. create Route table
54+
RouteTableData routeTableData = new RouteTableData()
55+
{
56+
Location = Location.WestUS2,
57+
};
58+
string routeTableName = "myRouteTable";
59+
var routeTable = await resourceGroup.GetRouteTables().CreateOrUpdateAsync(routeTableName, routeTableData);
60+
61+
//3. create vnet(subnet binding NetworkSecurityGroup and RouteTable)
62+
var vnetData = new VirtualNetworkData()
63+
{
64+
Location = Location.WestUS2,
65+
AddressSpace = new AddressSpace()
66+
{
67+
AddressPrefixes = { "10.10.0.0/16", }
68+
},
69+
Subnets =
70+
{
71+
new SubnetData()
72+
{
73+
Name = "ManagedInstance",
74+
AddressPrefix = "10.10.2.0/24",
75+
Delegations =
76+
{
77+
new Delegation() { ServiceName = "Microsoft.Sql/managedInstances",Name="Microsoft.Sql/managedInstances" ,Type="Microsoft.Sql"}
78+
},
79+
RouteTable = new RouteTableData(){ Id = routeTable.Value.Data.Id.ToString() },
80+
NetworkSecurityGroup = new NetworkSecurityGroupData(){ Id = networkSecurityGroup.Value.Data.Id.ToString() },
81+
}
82+
},
83+
};
84+
string vnetName = "myVnet";
85+
var vnet = await resourceGroup.GetVirtualNetworks().CreateOrUpdateAsync(vnetName, vnetData);
86+
string subnetId = $"{vnet.Value.Data.Id}/subnets/ManagedInstance";
87+
88+
//4. create ManagedInstance
89+
ManagedInstanceData data = new ManagedInstanceData(Location.WestUS2)
90+
{
91+
AdministratorLogin = "myAdministratorLogin",
92+
AdministratorLoginPassword = "abcdef123456789*",
93+
SubnetId = subnetId,
94+
PublicDataEndpointEnabled = false,
95+
MaintenanceConfigurationId = "/subscriptions/0000-0000-0000-0000/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default",
96+
ProxyOverride = new ManagedInstanceProxyOverride("Proxy") { },
97+
TimezoneId = "UTC",
98+
StorageAccountType = new StorageAccountType("GRS"),
99+
ZoneRedundant = false,
100+
};
101+
string managedInstanceName = "myManagedInstance";
102+
var managedInstanceLro = await resourceGroup.GetManagedInstances().CreateOrUpdateAsync(managedInstanceName, data);
103+
ManagedInstance managedInstance = managedInstanceLro.Value;
104+
```
105+
106+
***List all managed instance***
107+
108+
```C# Snippet:Managing_Sql_ListAllManagedInstances
109+
ManagedInstanceCollection managedInstanceCollection = resourceGroup.GetManagedInstances();
110+
111+
AsyncPageable<ManagedInstance> response = managedInstanceCollection.GetAllAsync();
112+
await foreach (ManagedInstance managedInstance in response)
113+
{
114+
Console.WriteLine(managedInstance.Data.Name);
115+
}
116+
```
117+
118+
***Get a managed instance***
119+
120+
```C# Snippet:Managing_Sql_GetAManagedInstance
121+
ManagedInstanceCollection managedInstanceCollection = resourceGroup.GetManagedInstances();
122+
123+
ManagedInstance managedInstance = await managedInstanceCollection.GetAsync("myManagedInstance");
124+
Console.WriteLine(managedInstance.Data.Name);
125+
```
126+
127+
***Try to get a managed instance if it exists***
128+
129+
```C# Snippet:Managing_Sql_GetAManagedInstanceIfExists
130+
ManagedInstanceCollection managedInstanceCollection = resourceGroup.GetManagedInstances();
131+
132+
ManagedInstance managedInstance = await managedInstanceCollection.GetIfExistsAsync("foo");
133+
if (managedInstance != null)
134+
{
135+
Console.WriteLine(managedInstance.Data.Name);
136+
}
137+
138+
if (await managedInstanceCollection.CheckIfExistsAsync("bar"))
139+
{
140+
Console.WriteLine("Virtual network 'bar' exists.");
141+
}
142+
```
143+
144+
***Delete a managed instance***
145+
146+
```C# Snippet:Managing_Sql_DeleteAManagedInstance
147+
ManagedInstanceCollection managedInstanceCollection = resourceGroup.GetManagedInstances();
148+
149+
ManagedInstance managedInstance = await managedInstanceCollection.GetAsync("myManagedInstance");
150+
await managedInstance.DeleteAsync();
151+
```
152+
153+
## Next steps
154+
155+
Take a look at the [Managing Managed Databases](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Sample2_ManagingManagedDatabases.md) samples.
156+
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Example: Managing the ManagedDatabases
2+
3+
>Note: Before getting started with the samples, go through the [prerequisites](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/resourcemanager/Azure.ResourceManager#prerequisites).
4+
5+
Namespaces for this example:
6+
```C# Snippet:Manage_Databases_Namespaces
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Threading.Tasks;
10+
using Azure.Core;
11+
using Azure.Identity;
12+
using Azure.ResourceManager.Network;
13+
using Azure.ResourceManager.Network.Models;
14+
using Azure.ResourceManager.Resources;
15+
using Azure.ResourceManager.Resources.Models;
16+
using Azure.ResourceManager.Sql.Models;
17+
using NUnit.Framework;
18+
```
19+
20+
When you first create your ARM client, choose the subscription you're going to work in. You can use the `GetDefaultSubscription`/`GetDefaultSubscriptionAsync` methods to return the default subscription configured for your user:
21+
22+
```C# Snippet:Readme_DefaultSubscription
23+
ArmClient armClient = new ArmClient(new DefaultAzureCredential());
24+
Subscription subscription = armClient.GetDefaultSubscription();
25+
```
26+
27+
This is a scoped operations object, and any operations you perform will be done under that subscription. From this object, you have access to all children via collection objects. Or you can access individual children by ID.
28+
29+
```C# Snippet:Readme_GetResourceGroupCollection
30+
ArmClient armClient = new ArmClient(new DefaultAzureCredential());
31+
Subscription subscription = await armClient.GetDefaultSubscriptionAsync();
32+
ResourceGroupCollection rgCollection = subscription.GetResourceGroups();
33+
// With the collection, we can create a new resource group with an specific name
34+
string rgName = "myRgName";
35+
Location location = Location.WestUS2;
36+
ResourceGroupCreateOrUpdateOperation lro = await rgCollection.CreateOrUpdateAsync(rgName, new ResourceGroupData(location));
37+
ResourceGroup resourceGroup = lro.Value;
38+
```
39+
40+
Now that we have the resource group created, we can manage the managed instance inside this resource group.
41+
42+
please notice that ManagedDatabases is sub resource of managed instance, before we create a ManagedDatabases, at lease we need to create a managed instance as prerequisite.Please refer to documentation of Azure.ResourceManager.Sql for details of creating a managed instance.
43+
44+
***Create a managed databases***
45+
46+
```C# Snippet:Managing_Sql_CreateAManagedDatabases
47+
ManagedDatabaseCollection managedDatabaseCollection = managedInstance.GetManagedDatabases();
48+
49+
ManagedDatabaseData data = new ManagedDatabaseData(Location.WestUS2)
50+
{
51+
};
52+
string databaseName = "myDatabase";
53+
var managedDatabaseLro = await managedDatabaseCollection.CreateOrUpdateAsync(databaseName, data);
54+
ManagedDatabase managedDatabase = managedDatabaseLro.Value;
55+
```
56+
57+
***List all managed databases***
58+
59+
```C# Snippet:Managing_Sql_ListAllManagedDatabases
60+
ManagedDatabaseCollection managedDatabaseCollection = managedInstance.GetManagedDatabases();
61+
62+
AsyncPageable<ManagedDatabase> response = managedDatabaseCollection.GetAllAsync();
63+
await foreach (ManagedDatabase managedDatabase in response)
64+
{
65+
Console.WriteLine(managedDatabase.Data.Name);
66+
}
67+
```
68+
69+
***Get a managed databases***
70+
71+
```C# Snippet:Managing_Sql_GetAManagedDatabases
72+
ManagedDatabaseCollection managedDatabaseCollection = managedInstance.GetManagedDatabases();
73+
74+
ManagedDatabase managedDatabase = await managedDatabaseCollection.GetAsync("myManagedDatabase");
75+
Console.WriteLine(managedDatabase.Data.Name);
76+
```
77+
78+
***Try to get a managed databases if it exists***
79+
80+
```C# Snippet:Managing_Sql_GetAManagedDatabasesIfExists
81+
ManagedDatabaseCollection managedDatabaseCollection = managedInstance.GetManagedDatabases();
82+
83+
ManagedDatabase managedDatabase = await managedDatabaseCollection.GetIfExistsAsync("foo");
84+
if (managedInstance != null)
85+
{
86+
Console.WriteLine(managedDatabase.Data.Name);
87+
}
88+
89+
if (await managedDatabaseCollection.CheckIfExistsAsync("bar"))
90+
{
91+
Console.WriteLine("Virtual network 'bar' exists.");
92+
}
93+
```
94+
95+
***Delete a managed databases***
96+
97+
```C# Snippet:Managing_Sql_DeleteAManagedDatabases
98+
ManagedDatabaseCollection managedDatabaseCollection = managedInstance.GetManagedDatabases();
99+
100+
ManagedDatabase managedDatabase = await managedDatabaseCollection.GetAsync("myManagedInstance");
101+
await managedDatabase.DeleteAsync();
102+
```
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<Version>1.0.0-preview.1</Version>
3+
<Version>1.0.0-beta.1</Version>
44
<PackageId>Azure.ResourceManager.Sql</PackageId>
55
<Description>Azure Resource Manager client SDK for Azure resource provider Microsoft.Sql</Description>
66
<PackageTags>azure;management;arm;resource manager;sql</PackageTags>
7-
<TemporaryUsePreviousGeneratorVersion>false</TemporaryUsePreviousGeneratorVersion>
8-
<IsMgmtSubLibrary>false</IsMgmtSubLibrary>
97
</PropertyGroup>
10-
11-
<PropertyGroup>
12-
<!-- TODO: As part of release process, this PropertyGroup can be removed once RP is approved for namespace -->
13-
<NoWarn>$(NoWarn);CS1591</NoWarn>
14-
<ExcludeMgmtCoreShared>true</ExcludeMgmtCoreShared>
15-
</PropertyGroup>
16-
17-
<ItemGroup>
18-
<PackageReference Include="Microsoft.Azure.AutoRest.CSharp" VersionOverride="$(MgmtAutorestVersion)" PrivateAssets="All" />
19-
</ItemGroup>
208
</Project>

sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/AdvisorData.cs

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)