https://pulumi.com logo
#azure
Title
# azure
g

glamorous-helmet-50600

04/12/2021, 4:28 PM
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

tall-librarian-49374

04/12/2021, 6:12 PM
Could you please share a repro so that I could try it?
g

glamorous-helmet-50600

04/12/2021, 6:16 PM
@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

tall-librarian-49374

04/12/2021, 6:20 PM
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

glamorous-helmet-50600

04/12/2021, 6:28 PM
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

tall-librarian-49374

04/12/2021, 6:29 PM
Are you getting a different exception for other resource types?
g

glamorous-helmet-50600

04/12/2021, 6:31 PM
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

tall-librarian-49374

04/12/2021, 6:50 PM
Is that one from the Azure SDK?
g

glamorous-helmet-50600

04/12/2021, 7:50 PM
Sorry I was away. Yeah definitely from the sdk
4 Views