public PSRemoteRenderingAccount(RemoteRenderingAccount another) :
     base(
         location: another.Location,
         id: another.Id,
         name: another.Name,
         type: another.Type,
         tags: new Dictionary <string, string>(another.Tags),
         accountId: another.AccountId,
         accountDomain: another.AccountDomain)
 {
     resourceId = new ResourceId(this.Id);
 }
Example #2
0
        private RemoteRenderingClient GetClient()
        {
            Guid   accountId               = new Guid(TestEnvironment.AccountId);
            string accountDomain           = TestEnvironment.AccountDomain;
            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);

            return(client);
        }
Example #3
0
        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);
        }
Example #4
0
        private RemoteRenderingClient GetClientWithStaticAccessToken()
        {
            Guid   accountId               = new Guid(TestEnvironment.AccountId);
            string accountDomain           = TestEnvironment.AccountDomain;
            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
            // MixedRealityStsClient and credentials to obtain an access token to be returned
            // to the client.
            AccessToken accessToken = GetMixedRealityAccessTokenFromWebService();

            RemoteRenderingClient client = new RemoteRenderingClient(remoteRenderingEndpoint, account, accessToken);
            #endregion Snippet:CreateAClientWithStaticAccessToken

            return(client);
        }
Example #5
0
        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
            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);
            #endregion Snippet:CreateAClientWithAAD
            return(client);
        }
Example #6
0
        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));
        }
 /// <summary>
 /// Creating or Updating a Remote Rendering Account.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of an Azure resource group.
 /// </param>
 /// <param name='accountName'>
 /// Name of an Mixed Reality Account.
 /// </param>
 /// <param name='remoteRenderingAccount'>
 /// Remote Rendering Account parameter.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <RemoteRenderingAccount> CreateAsync(this IRemoteRenderingAccountsOperations operations, string resourceGroupName, string accountName, RemoteRenderingAccount remoteRenderingAccount, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, accountName, remoteRenderingAccount, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Creating or Updating a Remote Rendering Account.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of an Azure resource group.
 /// </param>
 /// <param name='accountName'>
 /// Name of an Mixed Reality Account.
 /// </param>
 /// <param name='remoteRenderingAccount'>
 /// Remote Rendering Account parameter.
 /// </param>
 public static RemoteRenderingAccount Create(this IRemoteRenderingAccountsOperations operations, string resourceGroupName, string accountName, RemoteRenderingAccount remoteRenderingAccount)
 {
     return(operations.CreateAsync(resourceGroupName, accountName, remoteRenderingAccount).GetAwaiter().GetResult());
 }
Example #9
0
        public void TestRemoteRenderingAccountOperations()
        {
            var resourceGroup = new ResourceGroup
            {
                Name     = "MixedRealityNetSdkTests",
                Location = Location
            };

            var account = new RemoteRenderingAccount
            {
                Location = Location,
            };

            using (var context = StartTest())
            {
                var operations = Client.RemoteRenderingAccounts;

                try
                {
                    resourceGroup = ArmClient.ResourceGroups.CreateOrUpdate(resourceGroup.Name, resourceGroup);

                    // Create
                    AssertRemoteRenderingAccountNotExist(operations, resourceGroup.Name, RemoteRenderingAccountName);

                    account = operations.Create(resourceGroup.Name, RemoteRenderingAccountName, account);

                    Assert.Equal(RemoteRenderingAccountName, account.Name);
                    Assert.Equal(Location, account.Location);

                    // Read
                    account = operations.Get(resourceGroup.Name, RemoteRenderingAccountName);

                    Assert.Equal(RemoteRenderingAccountName, account.Name);
                    Assert.Equal(Location, account.Location);

                    // Primary Key
                    var oldKey = operations.ListKeys(resourceGroup.Name, account.Name).PrimaryKey;
                    var newKey = operations.RegenerateKeys(resourceGroup.Name, account.Name, 1).PrimaryKey;
                    Assert.NotEqual(oldKey, newKey);

                    // Secondary Key
                    oldKey = operations.ListKeys(resourceGroup.Name, account.Name).SecondaryKey;
                    newKey = operations.RegenerateKeys(resourceGroup.Name, account.Name, 2).SecondaryKey;
                    Assert.NotEqual(oldKey, newKey);

                    // Delete
                    operations.Delete(resourceGroup.Name, account.Name);

                    AssertRemoteRenderingAccountNotExist(operations, resourceGroup.Name, RemoteRenderingAccountName);
                }
                catch (CloudException e)
                {
                    Debug.Print(e.ToString());
                }
                finally
                {
                    // Delete is idempotent
                    operations.Delete(resourceGroup.Name, RemoteRenderingAccountName);

                    ArmClient.ResourceGroups.Delete(resourceGroup.Name);
                }
            }
        }