public async virtual Task <DeviceUpdateAccountCreateOperation> CreateOrUpdateAsync(string accountName, DeviceUpdateAccountData account, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (accountName == null) { throw new ArgumentNullException(nameof(accountName)); } if (account == null) { throw new ArgumentNullException(nameof(account)); } using var scope = _clientDiagnostics.CreateScope("DeviceUpdateAccountCollection.CreateOrUpdate"); scope.Start(); try { var response = await _deviceUpdateAccountsRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, accountName, account, cancellationToken).ConfigureAwait(false); var operation = new DeviceUpdateAccountCreateOperation(Parent, _clientDiagnostics, Pipeline, _deviceUpdateAccountsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, accountName, account).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task CreateAccounts() { #region Snippet:Managing_Accounts_CreateAnAccount // Get the account collection from the specific resource group and create an account string accountName = "myAccount"; DeviceUpdateAccountData input = new DeviceUpdateAccountData(Location.WestUS2); DeviceUpdateAccountCreateOperation lro = await resourceGroup.GetDeviceUpdateAccounts().CreateOrUpdateAsync(accountName, input); DeviceUpdateAccount account = lro.Value; #endregion Snippet:Managing_Accounts_CreateAnAccount }
public async Task CreateInstances() { #region Snippet:Managing_Instances_CreateAnInstance // Create a new account string accountName = "myAccount"; DeviceUpdateAccountData input1 = new DeviceUpdateAccountData(Location.WestUS2); DeviceUpdateAccountCreateOperation lro1 = await resourceGroup.GetDeviceUpdateAccounts().CreateOrUpdateAsync(accountName, input1); DeviceUpdateAccount account = lro1.Value; // Get the instance collection from the specific account and create an instance string instanceName = "myInstance"; DeviceUpdateInstanceData input2 = new DeviceUpdateInstanceData(Location.WestUS2); input2.IotHubs.Add(new IotHubSettings("/subscriptions/.../resourceGroups/.../providers/Microsoft.Devices/IotHubs/...")); DeviceUpdateInstanceCreateOperation lro2 = await account.GetDeviceUpdateInstances().CreateOrUpdateAsync(instanceName, input2); DeviceUpdateInstance instance = lro2.Value; #endregion Snippet:Managing_Instances_CreateAnInstance }