Afternoon guys, this is a bit weird but when tryin...
# azure
g
Afternoon guys, this is a bit weird but when trying to retrieve a resource that doesn't exist (in my case it's a Web.Certificate) I get an RpcException as expected BUT the status is "Unkown" instead of "ResourceNotFound", however on the Detail property of the RpcException I can see the correct Status and Statuscode...I want to catch specifically when the resource is not found but seems a bit weird to do
catch(Grpc.Core.RpcException ex) when ex.Status.Detail.Contains("ResourceNotFound")
t
Could you please share a repro so that I could try it?
g
@tall-librarian-49374
Copy code
try 
  {
    var getCertificateResult = AzureNative.Web.GetCertificate.InvokeAsync(new      AzureNative.Web.GetCertificateArgs {
                        Name = $"certtesddt-{name}-{env}",
                        ResourceGroupName = resourceGroupName
                    }).GetAwaiter().GetResult();
  }
  catch(Grpc.Core.RpcException ex) 
  {
    Console.WriteLine(ex.Status.StatusCode);
    Console.WriteLine("--------------------");
    Console.WriteLine(ex.Status.Detail.Contains("ResourceNotFound"));
              
  }
t
Thank you. I’m away from my computer but you can try running pulumi in debug mode to see the raw HTTP response from Azure and whether it’s a 404:
pulumi up --yes --skip-preview --debug -v=9 --logflow --logtostderr
g
ow that's an overwhelming amount of logs lol. Looking at the stacktrace we can definitely see that there's a ResourceNotFound and a StatusCode of 404 which I think must come from the azure response it's just confusing how the status on the exception is inconsistent with the Exception.Status.Detail property (which has a string where Status and StatusCode are as expected)
t
Are you getting a different exception for other resource types?
g
The only other instance where I do some sort of check is for Cosmos containers and/or documents, but then the exception I get is different (CosmosException)
t
Is that one from the Azure SDK?
g
Sorry I was away. Yeah definitely from the sdk