public async Task DeleteInstances() { #region Snippet:Managing_Instances_DeleteAnInstance // First we need to get the instance collection from the specific account DeviceUpdateAccountResource account = await resourceGroup.GetDeviceUpdateAccounts().GetAsync("myAccount"); DeviceUpdateInstanceCollection instanceCollection = account.GetDeviceUpdateInstances(); // Now we can get the instance with GetAsync() DeviceUpdateInstanceResource instance = await instanceCollection.GetAsync("myInstance"); // With DeleteAsync(), we can delete the instance await instance.DeleteAsync(WaitUntil.Completed); #endregion Snippet:Managing_Instances_DeleteAnInstance }
public async Task Delete() { SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-"); string accountName = Recording.GenerateAssetName("Account-"); DeviceUpdateAccountResource account = await CreateAccount(rg, accountName); string instanceName = Recording.GenerateAssetName("Instance-"); DeviceUpdateInstanceResource instance = await CreateInstance(account, instanceName); await instance.DeleteAsync(WaitUntil.Completed); var ex = Assert.ThrowsAsync <RequestFailedException>(async() => await instance.GetAsync()); Assert.AreEqual(404, ex.Status); }