public void QueryAndUpdateASession() { RemoteRenderingClient client = GetClientWithAccountKey(); string sessionId = Guid.NewGuid().ToString(); RenderingSessionOptions settings = new RenderingSessionOptions(TimeSpan.FromMinutes(30), RenderingServerSize.Standard); RenderingSession newSession = client.StartSession(sessionId, settings).WaitForCompletionAsync().Result; #region Snippet:UpdateSession RenderingSession currentSession = client.GetSession(sessionId); if (currentSession.MaxLeaseTime - DateTimeOffset.Now.Subtract(currentSession.CreatedOn.Value) < TimeSpan.FromMinutes(2)) { TimeSpan newLeaseTime = currentSession.MaxLeaseTime.Value.Add(TimeSpan.FromMinutes(30)); UpdateSessionOptions longerLeaseSettings = new UpdateSessionOptions(newLeaseTime); client.UpdateSession(sessionId, longerLeaseSettings); } #endregion Snippet:UpdateSession client.StopSession(sessionId); }
private RemoteRenderingClient GetClientWithDeviceCode() { Guid accountId = new Guid(TestEnvironment.AccountId); string accountDomain = TestEnvironment.AccountDomain; string tenantId = TestEnvironment.TenantId; string clientId = TestEnvironment.ClientId; Uri remoteRenderingEndpoint = new Uri(TestEnvironment.ServiceEndpoint); #region Snippet:CreateAClientWithDeviceCode RemoteRenderingAccount account = new RemoteRenderingAccount(accountId, accountDomain); Task deviceCodeCallback(DeviceCodeInfo deviceCodeInfo, CancellationToken cancellationToken) { Console.WriteLine(deviceCodeInfo.Message); return(Task.FromResult(0)); } TokenCredential credential = new DeviceCodeCredential(deviceCodeCallback, tenantId, clientId, new TokenCredentialOptions { AuthorityHost = new Uri($"https://login.microsoftonline.com/{tenantId}"), }); RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, credential); #endregion Snippet:CreateAClientWithDeviceCode return(client); }
public void CreateSession() { RemoteRenderingClient client = GetClientWithAccountKey(); #region Snippet:CreateASession RenderingSessionOptions options = new RenderingSessionOptions(TimeSpan.FromMinutes(30), RenderingServerSize.Standard); // A randomly generated GUID is a good choice for a sessionId. string sessionId = Guid.NewGuid().ToString(); StartRenderingSessionOperation startSessionOperation = client.StartSession(sessionId, options); RenderingSession newSession = startSessionOperation.WaitForCompletionAsync().Result; if (newSession.Status == RenderingSessionStatus.Ready) { Console.WriteLine($"Session {sessionId} is ready."); } else if (newSession.Status == RenderingSessionStatus.Error) { Console.WriteLine($"Session {sessionId} encountered an error: {newSession.Error.Code} {newSession.Error.Message}"); } #endregion Snippet:CreateASession // Use the session here. // ... // The session will automatically timeout, but in this sample we also demonstrate how to shut it down explicitly. #region Snippet:StopSession client.StopSession(sessionId); #endregion Snippet:StopSession }
public void ConvertMoreComplexAsset() { RemoteRenderingClient client = GetClient(); Uri inputStorageUri = new Uri($"https://{TestEnvironment.StorageAccountName}.blob.core.windows.net/{TestEnvironment.BlobContainerName}"); Uri outputStorageUri = new Uri($"https://{TestEnvironment.StorageAccountName}.blob.core.windows.net/{TestEnvironment.BlobContainerName}"); #region Snippet:StartAComplexAssetConversion AssetConversionInputOptions inputOptions = new AssetConversionInputOptions(inputStorageUri, "bicycle.gltf") { BlobPrefix = "Bicycle" }; AssetConversionOutputOptions outputOptions = new AssetConversionOutputOptions(outputStorageUri) { BlobPrefix = "ConvertedBicycle" }; AssetConversionOptions conversionOptions = new AssetConversionOptions(inputOptions, outputOptions); string conversionId = Guid.NewGuid().ToString(); AssetConversionOperation conversionOperation = client.StartConversion(conversionId, conversionOptions); #endregion Snippet:StartAComplexAssetConversion AssetConversion conversion = conversionOperation.WaitForCompletionAsync().Result; if (conversion.Status == AssetConversionStatus.Succeeded) { Console.WriteLine($"Conversion succeeded: Output written to {conversion.Output.OutputAssetUri}"); } else if (conversion.Status == AssetConversionStatus.Failed) { Console.WriteLine($"Conversion failed: {conversion.Error.Code} {conversion.Error.Message}"); } }
public void GetInformationAboutSessions() { RemoteRenderingClient client = GetClientWithAccountKey(); // Ensure there's at least one session to query. string sessionId = Guid.NewGuid().ToString(); RenderingSessionOptions settings = new RenderingSessionOptions(TimeSpan.FromMinutes(30), RenderingServerSize.Standard); client.StartSession(sessionId, settings); Thread.Sleep(TimeSpan.FromSeconds(10)); #region Snippet:ListSessions foreach (var properties in client.GetSessions()) { if (properties.Status == RenderingSessionStatus.Starting) { Console.WriteLine($"Session \"{properties.SessionId}\" is starting."); } else if (properties.Status == RenderingSessionStatus.Ready) { Console.WriteLine($"Session \"{properties.SessionId}\" is ready at host {properties.Host}"); } } #endregion Snippet:ListSessions client.StopSession(sessionId); }
public void ConvertSimpleAsset() { RemoteRenderingClient client = GetClient(); Uri storageUri = new Uri($"https://{TestEnvironment.StorageAccountName}.blob.core.windows.net/{TestEnvironment.BlobContainerName}"); #region Snippet:StartAnAssetConversion AssetConversionInputOptions inputOptions = new AssetConversionInputOptions(storageUri, "box.fbx"); AssetConversionOutputOptions outputOptions = new AssetConversionOutputOptions(storageUri); AssetConversionOptions conversionOptions = new AssetConversionOptions(inputOptions, outputOptions); // A randomly generated GUID is a good choice for a conversionId. string conversionId = Guid.NewGuid().ToString(); AssetConversionOperation conversionOperation = client.StartConversion(conversionId, conversionOptions); #endregion Snippet:StartAnAssetConversion #region Snippet:QueryAssetConversion AssetConversion conversion = conversionOperation.WaitForCompletionAsync().Result; if (conversion.Status == AssetConversionStatus.Succeeded) { Console.WriteLine($"Conversion succeeded: Output written to {conversion.Output.OutputAssetUri}"); } else if (conversion.Status == AssetConversionStatus.Failed) { Console.WriteLine($"Conversion failed: {conversion.Error.Code} {conversion.Error.Message}"); } #endregion Snippet:QueryAssetConversion }
private RemoteRenderingClient GetClient() { Guid accountId = new Guid(TestEnvironment.AccountId); string accountDomain = TestEnvironment.AccountDomain; string accountKey = TestEnvironment.AccountKey; Uri remoteRenderingEndpoint = new Uri(TestEnvironment.ServiceEndpoint); AzureKeyCredential accountKeyCredential = new AzureKeyCredential(accountKey); RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, accountKeyCredential); return(client); }
/// <summary> /// Demonstrates how to obtain a client with an AzureKeyCredential. /// Methods which demonstrate other authentication schemes are at the bottom of the file. /// </summary> /// <returns></returns> private RemoteRenderingClient GetClientWithAccountKey() { Guid accountId = new Guid(TestEnvironment.AccountId); string accountDomain = TestEnvironment.AccountDomain; string accountKey = TestEnvironment.AccountKey; 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); #endregion Snippet:CreateAClient return(client); }
private RemoteRenderingClient GetClientWithDefaultAzureCredential() { Guid accountId = new Guid(TestEnvironment.AccountId); string accountDomain = TestEnvironment.AccountDomain; 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); #endregion Snippet:CreateAClientWithAzureCredential return(client); }
public void GetConversions() { RemoteRenderingClient client = GetClient(); Console.WriteLine("Successful conversions since yesterday:"); #region Snippet:GetConversions foreach (var conversion in client.GetConversions()) { if ((conversion.Status == AssetConversionStatus.Succeeded) && (conversion.CreatedOn > DateTimeOffset.Now.AddDays(-1))) { Console.WriteLine($"output asset URI: {conversion.Output.OutputAssetUri}"); } } #endregion Snippet:GetConversions }
private RemoteRenderingClient GetClientWithStaticAccessToken() { Guid accountId = new Guid(TestEnvironment.AccountId); string accountDomain = TestEnvironment.AccountDomain; Uri remoteRenderingEndpoint = new Uri(TestEnvironment.ServiceEndpoint); #region Snippet:CreateAClientWithStaticAccessToken // 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, accountId, accountDomain, accessToken); #endregion Snippet:CreateAClientWithStaticAccessToken return(client); }
private RemoteRenderingClient GetClientWithAAD() { Guid accountId = new Guid(TestEnvironment.AccountId); string accountDomain = TestEnvironment.AccountDomain; string tenantId = TestEnvironment.TenantId; string clientId = TestEnvironment.ClientId; string clientSecret = TestEnvironment.ClientSecret; Uri remoteRenderingEndpoint = new Uri(TestEnvironment.ServiceEndpoint); #region Snippet:CreateAClientWithAAD TokenCredential credential = new ClientSecretCredential(tenantId, clientId, clientSecret, new TokenCredentialOptions { AuthorityHost = new Uri($"https://login.microsoftonline.com/{tenantId}") }); RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, accountId, accountDomain, credential); #endregion Snippet:CreateAClientWithAAD return(client); }
private RemoteRenderingClient GetClient() { RemoteRenderingAccount account = new RemoteRenderingAccount(new Guid(TestEnvironment.AccountId), TestEnvironment.AccountDomain); Uri serviceEndpoint = new Uri(TestEnvironment.ServiceEndpoint); var options = InstrumentClientOptions(new RemoteRenderingClientOptions()); // We don't need to test communication with the STS Authentication Library, so in playback // we use a code-path which does not attempt to contact that service. RemoteRenderingClient client; if (Mode != RecordedTestMode.Playback) { AzureKeyCredential accountKeyCredential = new AzureKeyCredential(TestEnvironment.AccountKey); client = new RemoteRenderingClient(serviceEndpoint, account, accountKeyCredential, options); } else { AccessToken artificialToken = new AccessToken("TestToken", DateTimeOffset.MaxValue); client = new RemoteRenderingClient(serviceEndpoint, account, artificialToken, options); } return(InstrumentClient(client)); }