diff --git a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/CHANGELOG.md b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/CHANGELOG.md
index 9fb14ce591f7..7d9b81de12f8 100644
--- a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/CHANGELOG.md
+++ b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/CHANGELOG.md
@@ -2,6 +2,7 @@
## 1.0.0-beta.3 (Unreleased)
- Allow the STS endpoint to be customized.
+- Changed constructors to align with guidance.
## 1.0.0-beta.2 (2021-02-16)
- Reflect minor REST API improvements.
diff --git a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/README.md b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/README.md
index 58b0f40c0811..cfa0ab37c66f 100644
--- a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/README.md
+++ b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/README.md
@@ -27,7 +27,7 @@ Install-Package Azure.MixedReality.RemoteRendering -AllowPrereleaseVersions
From .NET CLI
```dotnetcli
-dotnet add package Azure.MixedReality.RemoteRendering --version 1.0.0-beta.1
+dotnet add package Azure.MixedReality.RemoteRendering --version 1.0.0-beta.1
```
Add a package reference:
@@ -43,7 +43,6 @@ You will need an [Azure subscription](https://azure.microsoft.com/free/) and an
### Authenticate the client
Constructing a remote rendering client requires an authenticated account, and a remote rendering endpoint.
-A RemoteRenderingAccount object is constructed from an accountId and an account domain.
For an account created in the eastus region, the account domain will have the form "eastus.mixedreality.azure.com".
There are several different forms of authentication:
@@ -66,7 +65,7 @@ An example is `https://remoterendering.eastus2.mixedreality.azure.com`.
> NOTE: For converting assets, it is preferable to pick a region close to the storage containing the assets.
-> NOTE: For rendering, it is strongly recommended that you pick the closest region to the devices using the service.
+> NOTE: For rendering, it is strongly recommended that you pick the closest region to the devices using the service.
> The time taken to communicate with the server impacts the quality of the experience.
#### Authenticating with account key authentication
@@ -74,10 +73,9 @@ An example is `https://remoterendering.eastus2.mixedreality.azure.com`.
Use the `AccountKeyCredential` object to use an account identifier and account key to authenticate:
```csharp Snippet:CreateAClient
-RemoteRenderingAccount account = new RemoteRenderingAccount(accountId, accountDomain);
AzureKeyCredential accountKeyCredential = new AzureKeyCredential(accountKey);
-RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, accountKeyCredential);
+RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, accountKeyCredential);
```
#### Authenticating with an AAD client secret
@@ -85,14 +83,12 @@ RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint
Use the `ClientSecretCredential` object to perform client secret authentication.
```csharp Snippet:CreateAClientWithAAD
-RemoteRenderingAccount account = new RemoteRenderingAccount(accountId, accountDomain);
-
TokenCredential credential = new ClientSecretCredential(tenantId, clientId, clientSecret, new TokenCredentialOptions
{
AuthorityHost = new Uri($"https://login.microsoftonline.com/{tenantId}")
});
-RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, credential);
+RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, credential);
```
#### Authenticating a user using device code authentication
@@ -100,8 +96,6 @@ RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint
Use the `DeviceCodeCredential` object to perform device code authentication.
```csharp Snippet:CreateAClientWithDeviceCode
-RemoteRenderingAccount account = new RemoteRenderingAccount(accountId, accountDomain);
-
Task deviceCodeCallback(DeviceCodeInfo deviceCodeInfo, CancellationToken cancellationToken)
{
Debug.WriteLine(deviceCodeInfo.Message);
@@ -114,7 +108,7 @@ TokenCredential credential = new DeviceCodeCredential(deviceCodeCallback, tenant
AuthorityHost = new Uri($"https://login.microsoftonline.com/{tenantId}"),
});
-RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, credential);
+RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, credential);
```
See [here](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/Device-Code-Flow) for more
@@ -126,10 +120,9 @@ Use the `DefaultAzureCredential` object with `includeInteractiveCredentials: tru
flow:
```csharp Snippet:CreateAClientWithAzureCredential
-RemoteRenderingAccount account = new RemoteRenderingAccount(accountId, accountDomain);
TokenCredential credential = new DefaultAzureCredential(includeInteractiveCredentials: true);
-RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, credential);
+RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, credential);
```
#### Authenticating with a static access token
@@ -139,15 +132,13 @@ You can pass a Mixed Reality access token as an `AccessToken` previously retriev
to be used with a Mixed Reality client library:
```csharp Snippet:CreateAClientWithStaticAccessToken
-RemoteRenderingAccount account = new RemoteRenderingAccount(accountId, accountDomain);
-
// GetMixedRealityAccessTokenFromWebService is a hypothetical method that retrieves
// a Mixed Reality access token from a web service. The web service would use the
// MixedRealityStsClient and credentials to obtain an access token to be returned
// to the client.
AccessToken accessToken = GetMixedRealityAccessTokenFromWebService();
-RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, accessToken);
+RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, accessToken);
```
## Key concepts
diff --git a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/src/RemoteRenderingAccount.cs b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/src/RemoteRenderingAccount.cs
deleted file mode 100644
index ba8cb1d5d3ad..000000000000
--- a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/src/RemoteRenderingAccount.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-using Azure.Core;
-using System;
-
-namespace Azure.MixedReality.RemoteRendering
-{
- ///
- /// Represents Azure Remote Rendering account details.
- ///
- public class RemoteRenderingAccount
- {
- ///
- /// Gets the Azure Remote Rendering account domain.
- ///
- public string AccountDomain { get; }
-
- ///
- /// Gets the Azure Remote Rendering account identifier.
- ///
- public Guid AccountId { get; }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The Azure Remote Rendering account identifier.
- ///
- /// The Azure Remote Rendering account domain. For example, for an account created in the eastus region, this will have the form "eastus.mixedreality.azure.com".
- ///
- /// cannot be parsed as a Guid.
- public RemoteRenderingAccount(Guid accountId, string accountDomain)
- {
- Argument.AssertNotNullOrWhiteSpace(accountDomain, nameof(accountDomain));
- AccountId = accountId;
- AccountDomain = accountDomain;
- }
- }
-}
diff --git a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/src/RemoteRenderingClient.cs b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/src/RemoteRenderingClient.cs
index 1ad6e41d33b0..2ff346aaafcd 100644
--- a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/src/RemoteRenderingClient.cs
+++ b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/src/RemoteRenderingClient.cs
@@ -27,40 +27,54 @@ public class RemoteRenderingClient
/// Initializes a new instance of the class.
///
/// The rendering service endpoint. This determines the region in which the rendering VM is created.
- /// The Azure Remote Rendering account details.
- /// An access token used to access the specified Azure Remote Rendering account.
- /// The options.
- public RemoteRenderingClient(Uri remoteRenderingEndpoint, RemoteRenderingAccount account, AccessToken accessToken, RemoteRenderingClientOptions options = null)
- : this(remoteRenderingEndpoint, account, new StaticAccessTokenCredential(accessToken), options) { }
+ /// The Azure Remote Rendering account identifier.
+ /// The Azure Remote Rendering account domain.
+ /// The Azure Remote Rendering account primary or secondary key credential.
+ public RemoteRenderingClient(Uri remoteRenderingEndpoint, Guid accountId, string accountDomain, AzureKeyCredential keyCredential)
+ : this(remoteRenderingEndpoint, accountId, accountDomain, new MixedRealityAccountKeyCredential(accountId, keyCredential), null) { }
///
/// Initializes a new instance of the class.
///
/// The rendering service endpoint. This determines the region in which the rendering VM is created.
- /// The Azure Remote Rendering account details.
+ /// The Azure Remote Rendering account identifier.
+ /// The Azure Remote Rendering account domain.
/// The Azure Remote Rendering account primary or secondary key credential.
/// The options.
- public RemoteRenderingClient(Uri remoteRenderingEndpoint, RemoteRenderingAccount account, AzureKeyCredential keyCredential, RemoteRenderingClientOptions options = null)
- : this(remoteRenderingEndpoint, account, new MixedRealityAccountKeyCredential(account.AccountId, keyCredential), options) { }
+ public RemoteRenderingClient(Uri remoteRenderingEndpoint, Guid accountId, string accountDomain, AzureKeyCredential keyCredential, RemoteRenderingClientOptions options)
+ : this(remoteRenderingEndpoint, accountId, accountDomain, new MixedRealityAccountKeyCredential(accountId, keyCredential), options) { }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The rendering service endpoint. This determines the region in which the rendering VM is created.
+ /// The Azure Remote Rendering account identifier.
+ /// The Azure Remote Rendering account domain.
+ /// An access token used to access the specified Azure Remote Rendering account.
+ /// The options.
+ public RemoteRenderingClient(Uri remoteRenderingEndpoint, Guid accountId, string accountDomain, AccessToken accessToken, RemoteRenderingClientOptions options = null)
+ : this(remoteRenderingEndpoint, accountId, accountDomain, new StaticAccessTokenCredential(accessToken), options) { }
///
/// Initializes a new instance of the class.
///
/// The rendering service endpoint. This determines the region in which the rendering VM is created.
- /// The Azure Remote Rendering account details.
+ /// The Azure Remote Rendering account identifier.
+ /// The Azure Remote Rendering account domain.
/// The credential used to access the Mixed Reality service.
/// The options.
- public RemoteRenderingClient(Uri remoteRenderingEndpoint, RemoteRenderingAccount account, TokenCredential credential, RemoteRenderingClientOptions options = null)
+ public RemoteRenderingClient(Uri remoteRenderingEndpoint, Guid accountId, string accountDomain, TokenCredential credential, RemoteRenderingClientOptions options = null)
{
- Argument.AssertNotNull(account, nameof(account));
+ Argument.AssertNotDefault(ref accountId, nameof(accountId));
+ Argument.AssertNotNullOrWhiteSpace(accountDomain, nameof(accountDomain));
Argument.AssertNotNull(credential, nameof(credential));
options ??= new RemoteRenderingClientOptions();
- Uri authenticationEndpoint = options.AuthenticationEndpoint ?? AuthenticationEndpoint.ConstructFromDomain(account.AccountDomain);
- TokenCredential mrTokenCredential = MixedRealityTokenCredential.GetMixedRealityCredential(account.AccountId, authenticationEndpoint, credential);
+ Uri authenticationEndpoint = options.AuthenticationEndpoint ?? AuthenticationEndpoint.ConstructFromDomain(accountDomain);
+ TokenCredential mrTokenCredential = MixedRealityTokenCredential.GetMixedRealityCredential(accountId, authenticationEndpoint, credential);
- _accountId = account.AccountId;
+ _accountId = accountId;
_clientDiagnostics = new ClientDiagnostics(options);
_pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(mrTokenCredential, GetDefaultScope(remoteRenderingEndpoint)));
_restClient = new RemoteRenderingRestClient(_clientDiagnostics, _pipeline, remoteRenderingEndpoint.ToString(), options.Version);
diff --git a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/tests/RemoteRenderingLiveTests.cs b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/tests/RemoteRenderingLiveTests.cs
index fd6aba0bb93e..495fc91583d9 100644
--- a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/tests/RemoteRenderingLiveTests.cs
+++ b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/tests/RemoteRenderingLiveTests.cs
@@ -188,7 +188,8 @@ public void TestFailedSessionRequest()
private RemoteRenderingClient GetClient()
{
- RemoteRenderingAccount account = new RemoteRenderingAccount(new Guid(TestEnvironment.AccountId), TestEnvironment.AccountDomain);
+ Guid accountId = new Guid(TestEnvironment.AccountId);
+ string accountDomain = TestEnvironment.AccountDomain;
Uri serviceEndpoint = new Uri(TestEnvironment.ServiceEndpoint);
var options = InstrumentClientOptions(new RemoteRenderingClientOptions());
@@ -199,12 +200,12 @@ private RemoteRenderingClient GetClient()
if (Mode != RecordedTestMode.Playback)
{
AzureKeyCredential accountKeyCredential = new AzureKeyCredential(TestEnvironment.AccountKey);
- client = new RemoteRenderingClient(serviceEndpoint, account, accountKeyCredential, options);
+ client = new RemoteRenderingClient(serviceEndpoint, accountId, accountDomain, accountKeyCredential, options);
}
else
{
AccessToken artificialToken = new AccessToken("TestToken", DateTimeOffset.MaxValue);
- client = new RemoteRenderingClient(serviceEndpoint, account, artificialToken, options);
+ client = new RemoteRenderingClient(serviceEndpoint, accountId, accountDomain, artificialToken, options);
}
return InstrumentClient(client);
}
diff --git a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/tests/Samples/RemoteRenderingConvertAssetSample.cs b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/tests/Samples/RemoteRenderingConvertAssetSample.cs
index 38bef3465b09..c037850807d0 100644
--- a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/tests/Samples/RemoteRenderingConvertAssetSample.cs
+++ b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/tests/Samples/RemoteRenderingConvertAssetSample.cs
@@ -20,10 +20,9 @@ private RemoteRenderingClient GetClient()
string accountKey = TestEnvironment.AccountKey;
Uri remoteRenderingEndpoint = new Uri(TestEnvironment.ServiceEndpoint);
- RemoteRenderingAccount account = new RemoteRenderingAccount(accountId, accountDomain);
AzureKeyCredential accountKeyCredential = new AzureKeyCredential(accountKey);
- RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, accountKeyCredential);
+ RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, accountKeyCredential);
return client;
}
diff --git a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/tests/Samples/RemoteRenderingCreateSessionSample.cs b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/tests/Samples/RemoteRenderingCreateSessionSample.cs
index 1588388cb126..92f9cf0f79b9 100644
--- a/sdk/mixedreality/Azure.MixedReality.RemoteRendering/tests/Samples/RemoteRenderingCreateSessionSample.cs
+++ b/sdk/mixedreality/Azure.MixedReality.RemoteRendering/tests/Samples/RemoteRenderingCreateSessionSample.cs
@@ -27,10 +27,9 @@ private RemoteRenderingClient GetClientWithAccountKey()
Uri remoteRenderingEndpoint = new Uri(TestEnvironment.ServiceEndpoint);
#region Snippet:CreateAClient
- RemoteRenderingAccount account = new RemoteRenderingAccount(accountId, accountDomain);
AzureKeyCredential accountKeyCredential = new AzureKeyCredential(accountKey);
- RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, accountKeyCredential);
+ RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, accountKeyCredential);
#endregion Snippet:CreateAClient
return client;
}
@@ -146,14 +145,13 @@ private RemoteRenderingClient GetClientWithAAD()
Uri remoteRenderingEndpoint = new Uri(TestEnvironment.ServiceEndpoint);
#region Snippet:CreateAClientWithAAD
- RemoteRenderingAccount account = new RemoteRenderingAccount(accountId, accountDomain);
TokenCredential credential = new ClientSecretCredential(tenantId, clientId, clientSecret, new TokenCredentialOptions
{
AuthorityHost = new Uri($"https://login.microsoftonline.com/{tenantId}")
});
- RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, credential);
+ RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, credential);
#endregion Snippet:CreateAClientWithAAD
return client;
}
@@ -167,7 +165,6 @@ private RemoteRenderingClient GetClientWithDeviceCode()
Uri remoteRenderingEndpoint = new Uri(TestEnvironment.ServiceEndpoint);
#region Snippet:CreateAClientWithDeviceCode
- RemoteRenderingAccount account = new RemoteRenderingAccount(accountId, accountDomain);
Task deviceCodeCallback(DeviceCodeInfo deviceCodeInfo, CancellationToken cancellationToken)
{
@@ -180,7 +177,7 @@ Task deviceCodeCallback(DeviceCodeInfo deviceCodeInfo, CancellationToken cancell
AuthorityHost = new Uri($"https://login.microsoftonline.com/{tenantId}"),
});
- RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, credential);
+ RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, credential);
#endregion Snippet:CreateAClientWithDeviceCode
return client;
}
@@ -192,10 +189,10 @@ private RemoteRenderingClient GetClientWithDefaultAzureCredential()
Uri remoteRenderingEndpoint = new Uri(TestEnvironment.ServiceEndpoint);
#region Snippet:CreateAClientWithAzureCredential
- RemoteRenderingAccount account = new RemoteRenderingAccount(accountId, accountDomain);
+
TokenCredential credential = new DefaultAzureCredential(includeInteractiveCredentials: true);
- RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, credential);
+ RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, credential);
#endregion Snippet:CreateAClientWithAzureCredential
return client;
@@ -213,7 +210,6 @@ private RemoteRenderingClient GetClientWithStaticAccessToken()
Uri remoteRenderingEndpoint = new Uri(TestEnvironment.ServiceEndpoint);
#region Snippet:CreateAClientWithStaticAccessToken
- RemoteRenderingAccount account = new RemoteRenderingAccount(accountId, accountDomain);
// GetMixedRealityAccessTokenFromWebService is a hypothetical method that retrieves
// a Mixed Reality access token from a web service. The web service would use the
@@ -221,7 +217,7 @@ private RemoteRenderingClient GetClientWithStaticAccessToken()
// to the client.
AccessToken accessToken = GetMixedRealityAccessTokenFromWebService();
- RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, accessToken);
+ RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, accessToken);
#endregion Snippet:CreateAClientWithStaticAccessToken
return client;