public virtual Response <SqlDatabaseResource> Get(CancellationToken cancellationToken = default) { using var scope = _sqlDatabaseSqlResourcesClientDiagnostics.CreateScope("SqlDatabaseResource.Get"); scope.Start(); try { var response = _sqlDatabaseSqlResourcesRestClient.GetSqlDatabase(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new SqlDatabaseResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <SqlDatabase> Get(string databaseName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(databaseName, nameof(databaseName)); using var scope = _sqlDatabaseSqlResourcesClientDiagnostics.CreateScope("SqlDatabaseCollection.Get"); scope.Start(); try { var response = _sqlDatabaseSqlResourcesRestClient.GetSqlDatabase(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, databaseName, cancellationToken); if (response.Value == null) { throw _sqlDatabaseSqlResourcesClientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new SqlDatabase(ArmClient, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }