private PSDeletedKeyVaultKey GetDeletedKey(KeyClient client, string keyName) { DeletedKey deletedKeyBundle; try { deletedKeyBundle = client.GetDeletedKeyAsync(keyName).GetAwaiter().GetResult(); } catch (RequestFailedException ex) { if (ex.Status == (int)HttpStatusCode.NotFound) { return(null); } else { throw; } } catch (Exception ex) { throw GetInnerException(ex); } return(new PSDeletedKeyVaultKey(deletedKeyBundle, _uriHelper, isHsm: true)); }
private async Task <bool> WaitForDeletedKeyAsync(KeyClient client, string keyName) { int maxIterations = 20; for (int i = 0; i < maxIterations; i++) { try { await client.GetDeletedKeyAsync(keyName); return(true); } catch { await Task.Delay(5000); } } return(false); }