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

gentle-airplane-84691

07/12/2022, 1:37 PM
is there a way to delete and create an existing queue in service bus?
c

clever-sunset-76585

07/12/2022, 2:42 PM
If you are asking this question I am assuming the queue wasn't created via Pulumi? Or was it?
g

gentle-airplane-84691

07/12/2022, 11:58 PM
the queue is already in azure, i want to update or recreate it
and also i want to check if a queue is already in azure
i tried using Queue.Get, but it always throws an error if the queue does not exist i have a try catch, but it still fails saying that the error is unhandled
c

clever-sunset-76585

07/13/2022, 12:48 AM
Yeah Queue.Get is assertive and you will not be able to catch the exception as the program exits early before you can catch it. Instead, use there should be a
GetQueueAsync
or a similar function in the same namespace as the ServiceBus. Those are known as lookup functions and will allow you to catch the exception.
g

gentle-airplane-84691

07/13/2022, 12:49 AM
thanks I will try this
c

clever-sunset-76585

07/13/2022, 12:49 AM
If the queue is already there, do you want Pulumi to manage it? If so you can import it into your stack first so that Pulumi takes over the queue resource and you can modify it after that just like any other resource.
g

gentle-airplane-84691

07/13/2022, 12:50 AM
how is that done tho?
c

clever-sunset-76585

07/13/2022, 12:50 AM
Search for docs about importing resources. There is also a CLI command that should help generate the code snippet you can use to import the resource.
g

gentle-airplane-84691

07/13/2022, 12:51 AM
got it. thank you
c

clever-sunset-76585

07/13/2022, 12:52 AM
With that you should ensure that nothing else is trying to update the queue resource outside of Pulumi. Otherwise you'll see a diff in your Pulumi previews frequently.
g

gentle-airplane-84691

07/13/2022, 12:53 AM
got it. actually i was planning on just letting pulumi handle the service bus, without interactions from humans. aside from creating it
👍 1
i tried using this code, but in the preview it only shows delete
c

clever-sunset-76585

07/13/2022, 2:38 AM
I didn't quite understand what you mean by that. Can you share the diff with me privately?
g

gentle-airplane-84691

07/13/2022, 2:43 AM
sure
7 Views