public async Task IotCentralApplicationCrudOperationsTest() { var appName = Recording.GenerateAssetName("test-app-"); // Get IoT Central apps collection for resource group. var subscription = Client.GetSubscriptionResource(new ResourceIdentifier($"/subscriptions/{SessionEnvironment.SubscriptionId}")); var rg = await CreateResourceGroupAsync(subscription, "sdk-test-rg-"); var appsCollection = rg.GetIotCentralApps(); // Create IoT Central application. var iotCentralAppData = new IotCentralAppData(AzureLocation.WestUS, new AppSkuInfo(AppSku.ST0)) { DisplayName = appName, Subdomain = appName, }; await appsCollection.CreateOrUpdateAsync(WaitUntil.Completed, appName, iotCentralAppData, CancellationToken.None); // Read IoT Central application. var iotCentralAppResponse = await appsCollection.GetAsync(appName, CancellationToken.None); var iotCentralApp = iotCentralAppResponse.Value; // Update IoT Central application. var iotCentralAppPatch = new IotCentralAppPatch() { Sku = new AppSkuInfo(AppSku.ST1), Identity = new SystemAssignedServiceIdentity(ResourceManager.Models.SystemAssignedServiceIdentityType.SystemAssigned), }; await iotCentralApp.UpdateAsync(WaitUntil.Completed, iotCentralAppPatch, CancellationToken.None); // Delete IoT Central application. await iotCentralApp.DeleteAsync(WaitUntil.Completed, CancellationToken.None); }
public virtual ArmOperation Update(WaitUntil waitUntil, IotCentralAppPatch patch, CancellationToken cancellationToken = default) { Argument.AssertNotNull(patch, nameof(patch)); using var scope = _iotCentralAppAppsClientDiagnostics.CreateScope("IotCentralAppResource.Update"); scope.Start(); try { var response = _iotCentralAppAppsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); var operation = new IotCentralArmOperation(_iotCentralAppAppsClientDiagnostics, Pipeline, _iotCentralAppAppsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletionResponse(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }