Friday, April 19, 2024
HomeC#Azure Capabilities, perform.json, Visible Studio 2022 and proxies.json, deploy, deployment | The...

Azure Capabilities, perform.json, Visible Studio 2022 and proxies.json, deploy, deployment | The Greatest C# Programmer In The World


A couple of fascinating situations I skilled that I needed to doc.  Firstly, there’s loads of deal with Visible Studio Code, I’m nonetheless engaged on ramping up there and aligning with and contributing the momentum it’s constructing.  I see Visible Studio Code because the place the place those that need to get into Open Supply stuff, however have been with Microsoft for very long time.  If you’ll study some new coding language, may as effectively use the IDE which is concentrated there.  That’s not saying that Visible Studio (not Code) doesn’t assist Open Supply, it does, however like I mentioned, why not align completely with the momentum in case you are dipping into Open Supply.

Anyway, I used to be attempting to do some testing and needed so as to add a file, particularly the proxies.json to an Azure Operate.  I added it to the basis of my venture, as proven, however once I deployed it didn’t present up.

Determine 1, including information to an Azure Capabilities Visible Studio 2022 venture

The factor is, while you deploy an Azure Operate it’s defaulted to run WEBSITE_RUN_FROM_PACKAGE.  This if fantastic and optimum.  What this implies is for those who attempt to add the Proxy manually, you can’t as a result of the Azure Operate is in read-only mode when WEBSITE_RUN_FROM_PACKAGE is enabled.  Making an attempt to quickly setting WEBSITE_RUN_FROM_PACKAGE to 0 won’t work both.

image

Determine 2, can not make modifications to an Azure Operate when WEBSITE_RUN_FROM_PACKAGE is enabled

The answer is to change the properties of the proxies.json file in order that it will get copied into the Output Listing.  As soon as that occurs, all is sweet.

image

Determine 3, change file properties to incorporate the file in Visible Studio construct

Which leads me to the actual problem I had, which was making a change to the features.json file in Visible Studio, which once more, didn’t publish once I modified it.  I needed to set IsSessionEnabled = true for a Service Bus triggered Azure Operate.  So, I went to the supply.  Meaning, the information are generated throughout the construct, so I modified the perform.json file in each the Debug and Launch listing, however the change was overwritten throughout the construct course of.  I believe this is by-design.

  • C:Usersbenperksourcereposcsharpguitar-vscsharpguitar-vsbinLaunchnetcoreapp3.1servicebus
  • C:Usersbenperksourcereposcsharpguitar-vscsharpguitar-vsbinDebugnetcoreapp3.1servicebus

I assumed, hey it labored for proxies.json, when not use that very same strategy with this perform.json.  So I clicked the Present Hidden Information button and navigated to the perform.json, clicked it and didn’t see any properties that might let me embody this file into the Output Listing, it was empty.

image

Determine 4, the place is the perform.json, embody modifications with Visible Studio

What lead me to a working resolution was this remark within the GitHub article I linked to above, right here it’s once more incase you missed it: “as a result of enter and output bindings will likely be learn straight from the meeting attributes”.  So the answer for me was so as to add the binding attribute within the Run() technique declaration listing within the code.

image

Determine 5, perform.json modifications don’t deploy with Visible Studio, the right way to

public static void Run(
   [ServiceBusTrigger("csharpguitar", IsSessionsEnabled = true, Connection = "SB_CONN")]string myQueueItem, ILogger log)
   {
       log.LogInformation($"C# ServiceBus queue set off perform processed message: {myQueueItem}");
   }

The complicated a part of that is that I needed to put additionally set autoComplete = false, however you can’t try this within the Run() technique declaration, or at the very least I didn’t discover it.  As an alternative you set that within the host.json.  The documentation does state that autoComplete is a perform.json attribute.  The factor is, your Run() runs inside the Azure Capabilities Host, so apparently the administration of the autoComplete functionality was coded into the host, which the implementation of the Session Administration is within the Operate. 

Both manner, I’m profitable now in my effort and I can proceed with the work I would like to finish that required me to study what I documented right here earlier than I might begin it.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments