Skip to content

Commit cfcb0c4

Browse files
authored
Refactor CloudMachineClient and related types into new package (Azure#46937)
1 parent dd9fd2d commit cfcb0c4

29 files changed

+804
-415
lines changed

.github/CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@
180180
# ServiceLabel: %Bot Service
181181
# ServiceOwners: @sgellock
182182

183+
# PRLabel: %Cloud Machine
184+
/sdk/cloudmachine/ @christothes @KrzysztofCwalina
185+
186+
# ServiceLabel: %Cloud Machine
187+
# AzureSdkOwners: @christothes @KrzysztofCwalina
188+
183189
# PRLabel: %Cognitive - Language
184190
/sdk/cognitivelanguage/ @quentinRobinson @bidisha-c
185191

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure.CloudMachine", "Azure.CloudMachine", "{780138CF-68C6-4323-982F-F18989E2FA86}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.CloudMachine", "Azure.CloudMachine\src\Azure.CloudMachine.csproj", "{0EA29D2F-41E0-4826-9CD4-111109A2CFF7}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.CloudMachine.Tests", "Azure.CloudMachine\tests\Azure.CloudMachine.Tests.csproj", "{8C1A29AE-E357-4C40-ACCC-7215FBFB368C}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
21+
{0EA29D2F-41E0-4826-9CD4-111109A2CFF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22+
{0EA29D2F-41E0-4826-9CD4-111109A2CFF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
23+
{0EA29D2F-41E0-4826-9CD4-111109A2CFF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
24+
{0EA29D2F-41E0-4826-9CD4-111109A2CFF7}.Release|Any CPU.Build.0 = Release|Any CPU
25+
{8C1A29AE-E357-4C40-ACCC-7215FBFB368C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{8C1A29AE-E357-4C40-ACCC-7215FBFB368C}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{8C1A29AE-E357-4C40-ACCC-7215FBFB368C}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{8C1A29AE-E357-4C40-ACCC-7215FBFB368C}.Release|Any CPU.Build.0 = Release|Any CPU
29+
EndGlobalSection
30+
GlobalSection(NestedProjects) = preSolution
31+
{0EA29D2F-41E0-4826-9CD4-111109A2CFF7} = {780138CF-68C6-4323-982F-F18989E2FA86}
32+
{8C1A29AE-E357-4C40-ACCC-7215FBFB368C} = {780138CF-68C6-4323-982F-F18989E2FA86}
33+
EndGlobalSection
34+
EndGlobal
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Release History
2+
3+
## 1.0.0-beta.1 (Unreleased)
4+
5+
### Features Added
6+
7+
### Breaking Changes
8+
9+
### Bugs Fixed
10+
11+
### Other Changes
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<!--
3+
Add any shared properties you want for the projects under this package directory that need to be set before the auto imported Directory.Build.props
4+
-->
5+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.props))\Directory.Build.props" />
6+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<!-- Import the common SDK build targets. -->
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.targets))\Directory.Build.targets"
4+
Condition="'$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.targets))' != ''" />
5+
6+
</Project>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Azure CloudMachine client library for .NET
2+
3+
TODO
4+
5+
## Getting started
6+
7+
### Install the package
8+
9+
Install the client library for .NET with [NuGet](https://www.nuget.org/ ):
10+
11+
```dotnetcli
12+
dotnet add package Azure.CloudMachine --prerelease
13+
```
14+
15+
### Prerequisites
16+
17+
> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/).
18+
19+
### Authenticate the Client
20+
21+
## Key concepts
22+
23+
TODO.
24+
25+
## Examples
26+
27+
## Troubleshooting
28+
29+
- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues).
30+
- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags.
31+
32+
## Next steps
33+
34+
## Contributing
35+
36+
For details on contributing to this repository, see the [contributing
37+
guide][cg].
38+
39+
This project welcomes contributions and suggestions. Most contributions
40+
require you to agree to a Contributor License Agreement (CLA) declaring
41+
that you have the right to, and actually do, grant us the rights to use
42+
your contribution. For details, visit <https://cla.microsoft.com>.
43+
44+
When you submit a pull request, a CLA-bot will automatically determine
45+
whether you need to provide a CLA and decorate the PR appropriately
46+
(for example, label, comment). Follow the instructions provided by the
47+
bot. You'll only need to do this action once across all repositories
48+
using our CLA.
49+
50+
This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For
51+
more information, see the [Code of Conduct FAQ][coc_faq] or contact
52+
<[email protected]> with any other questions or comments.
53+
54+
<!-- LINKS -->
55+
[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md
56+
[coc]: https://opensource.microsoft.com/codeofconduct/
57+
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
namespace Azure.CloudMachine
2+
{
3+
public partial class CloudMachineClient : Azure.CloudMachine.CloudMachineWorkspace
4+
{
5+
protected CloudMachineClient() : base (default(Azure.Core.TokenCredential), default(Microsoft.Extensions.Configuration.IConfiguration)) { }
6+
public CloudMachineClient(Azure.Core.TokenCredential credential = null, Microsoft.Extensions.Configuration.IConfiguration configuration = null) : base (default(Azure.Core.TokenCredential), default(Microsoft.Extensions.Configuration.IConfiguration)) { }
7+
public Azure.CloudMachine.MessagingServices Messaging { get { throw null; } }
8+
public Azure.CloudMachine.StorageServices Storage { get { throw null; } }
9+
}
10+
public partial class CloudMachineWorkspace : Azure.Core.ClientWorkspace
11+
{
12+
public CloudMachineWorkspace(Azure.Core.TokenCredential credential = null, Microsoft.Extensions.Configuration.IConfiguration configuration = null) { }
13+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
14+
public string Id { get { throw null; } }
15+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
16+
public override bool Equals(object obj) { throw null; }
17+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
18+
public override Azure.Core.ClientConnectionOptions GetConnectionOptions(System.Type clientType, string instanceId = null) { throw null; }
19+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
20+
public override int GetHashCode() { throw null; }
21+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
22+
public override string ToString() { throw null; }
23+
}
24+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
25+
public readonly partial struct MessagingServices
26+
{
27+
private readonly object _dummy;
28+
private readonly int _dummyPrimitive;
29+
public void SendMessage(object serializable) { }
30+
public void WhenMessageReceived(System.Action<string> received) { }
31+
}
32+
public partial class StorageFile
33+
{
34+
internal StorageFile() { }
35+
public System.Threading.CancellationToken CancellationToken { get { throw null; } }
36+
public string Path { get { throw null; } }
37+
public string RequestId { get { throw null; } }
38+
public void Delete() { }
39+
public System.BinaryData Download() { throw null; }
40+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
41+
public override bool Equals(object obj) { throw null; }
42+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
43+
public override int GetHashCode() { throw null; }
44+
public static implicit operator Azure.Response (Azure.CloudMachine.StorageFile result) { throw null; }
45+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
46+
public override string ToString() { throw null; }
47+
}
48+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
49+
public readonly partial struct StorageServices
50+
{
51+
private readonly object _dummy;
52+
private readonly int _dummyPrimitive;
53+
public void DeleteBlob(string path) { }
54+
public System.BinaryData DownloadBlob(string path) { throw null; }
55+
public string UploadBinaryData(System.BinaryData data, string name = null, bool overwrite = false) { throw null; }
56+
public string UploadBytes(byte[] bytes, string name = null, bool overwrite = false) { throw null; }
57+
public string UploadBytes(System.ReadOnlyMemory<byte> bytes, string name = null, bool overwrite = false) { throw null; }
58+
public string UploadJson(object json, string name = null, bool overwrite = false) { throw null; }
59+
public string UploadStream(System.IO.Stream fileStream, string name = null, bool overwrite = false) { throw null; }
60+
public void WhenBlobUploaded(System.Action<Azure.CloudMachine.StorageFile> function) { }
61+
}
62+
}
63+
namespace Azure.CloudMachine.KeyVault
64+
{
65+
public static partial class KeyVaultExtensions
66+
{
67+
public static Azure.Security.KeyVault.Secrets.SecretClient GetKeyVaultSecretsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
68+
}
69+
}
70+
namespace Azure.CloudMachine.OpenAI
71+
{
72+
public static partial class AzureOpenAIExtensions
73+
{
74+
public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
75+
public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
76+
}
77+
}
78+
namespace Azure.Core
79+
{
80+
public partial class ClientCache
81+
{
82+
public ClientCache() { }
83+
public T Get<T>(System.Func<T> value, string id = null) where T : class { throw null; }
84+
}
85+
public enum ClientConnectionKind
86+
{
87+
EntraId = 0,
88+
ApiKey = 1,
89+
OutOfBand = 2,
90+
}
91+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
92+
public readonly partial struct ClientConnectionOptions
93+
{
94+
private readonly object _dummy;
95+
private readonly int _dummyPrimitive;
96+
public ClientConnectionOptions(string subclientId) { throw null; }
97+
public ClientConnectionOptions(System.Uri endpoint, Azure.Core.TokenCredential credential) { throw null; }
98+
public ClientConnectionOptions(System.Uri endpoint, string apiKey) { throw null; }
99+
public string ApiKeyCredential { get { throw null; } }
100+
public Azure.Core.ClientConnectionKind ConnectionKind { get { throw null; } }
101+
public System.Uri Endpoint { get { throw null; } }
102+
public string Id { get { throw null; } }
103+
public Azure.Core.TokenCredential TokenCredential { get { throw null; } }
104+
}
105+
public abstract partial class ClientWorkspace
106+
{
107+
protected ClientWorkspace() { }
108+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
109+
public Azure.Core.ClientCache Subclients { get { throw null; } }
110+
public abstract Azure.Core.ClientConnectionOptions GetConnectionOptions(System.Type clientType, string instanceId = null);
111+
}
112+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
page_type: sample
3+
languages:
4+
- csharp
5+
products:
6+
# Including relevant stubs from https://review.docs.microsoft.com/help/contribute/metadata-taxonomies#product
7+
- azure
8+
name: Azure.CloudMachine samples for .NET
9+
description: Samples for the Azure.CloudMachine client library.
10+
---
11+
12+
# Azure.CloudMachine Samples
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Description>Azure.CloudMachine simplifies getting started with Azure in .NET.</Description>
5+
<Version>1.0.0-beta.1</Version>
6+
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
7+
<LangVersion>12</LangVersion>
8+
9+
<!-- Disable warning CS1591: Missing XML comment for publicly visible type or member -->
10+
<NoWarn>CS1591</NoWarn>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Azure.Core" />
15+
<PackageReference Include="Azure.AI.OpenAI" />
16+
<PackageReference Include="Azure.Identity" />
17+
<PackageReference Include="Azure.Messaging.ServiceBus" />
18+
<PackageReference Include="Azure.Messaging.EventGrid" />
19+
<PackageReference Include="Azure.Storage.Blobs" />
20+
<PackageReference Include="Azure.Security.KeyVault.Secrets" />
21+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" VersionOverride="8.0.0" />
22+
</ItemGroup>
23+
24+
</Project>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ namespace Azure.Core;
99
// TODO: this is a very demo implementation. We need to do better
1010
public class ClientCache
1111
{
12-
private readonly Dictionary<(Type, string?), object> _clients = new Dictionary<(Type, string?), object>();
12+
private readonly Dictionary<(Type, string), object> _clients = new Dictionary<(Type, string), object>();
1313

14-
public T Get<T>(Func<T> value, string? id = default) where T: class
14+
public T Get<T>(Func<T> value, string id = default) where T: class
1515
{
1616
var client = (typeof(T), id);
1717
lock (_clients)

0 commit comments

Comments
 (0)