Visual Studio Toolbox

Visual Studio Tools for Azure Functions

Rate this post
(Video Transcript)

>> Hi, welcome to Visual Studio Toolbox. I’m your host, Robert Green. Joining me today is Andrew Hall. Hey, Andrew.

>> Hi, Robert.

>> Welcome back on the show.

>> Thank you very much.

>> Been on the show a number of times talking about debugging stuff. But you’ve moved to a different team now.

>> I did, yeah, I moved over to the Web and Cloud Tools team.

>> Excellent.

>> So still in Visual Studio, so it was a small move.

>> But not the debugger guy anymore.

>> So we’re gonna talk about some cloud tooling today.

>> Yeah.

>> We’re gonna talk about the Visual Studio tools for Azure functions. It’s probably not the official name. But basically, Visual Studio tooling for Azure functions.

>> Correct, and I’ll point out really early on that this is a preview.

>> That’s cool.

>> It’s an early preview, so it has like a version 0.1 or something on it.

>> That’s fine, that’s fine. So I know Azure functions have been covered quite a bit on shows like Cloud Cover, so we’re gonna do a brief overview of what they are and why you care. And then I’ve seen a number of demos on them, and you always write the code in the browser. But you’re gonna show us how you can write the code in Visual Studio.

>> Correct.

>> All right, so what are Azure functions?

>> Yeah, so Azure functions, we’ll briefly just jump to the portal. So Azure functions are the ability to write event-based things in, as a better way to say it, so you have an event that occurs and you want a little bit of code that runs to process it. So a term that gets used a lot is serverless computing. So the idea is you have some code that execute based on some event.

>> Serverless.

>> Yeah, so the idea, instead of normally with a normal ASP.NET website or something, you have sort of this dedicated endpoint that’s executing. And it’s always available and you’re sort of always paying for server resources to have that up and running.

>> Okay.

>> And the idea behind serverless computing is you’re on a shared infrastructure that can infinitely scale in the cloud and in Azure. But what you can do is you can say, I only want to pay for the time that I consume.

>> Okay.

>> So the way that Azure functions work is it’s a function of the CPU time and the amount of RAM that your functions use while it executes.

>> Okay.

>> So you basically pay per 100 milliseconds that your functions execute in Azure. And they give you quite a bit of sort of free runway, so you can run quite a bit of functions. That’s the idea behind serverless.

>> Okay.

>> It’s there, but you’re only paying for the resources that you’re consuming as opposed to paying for a dedicated endpoint that’s always available.

>> And because you’re running it in Azure, the servers are all set up, the infrastructure is all set up. You just have to run some code, wire it up, wait for the events, wait for the code to run.

>> Correct, and it’s all based on triggers. So I just have sort of simple function app here in the portal, which is what you talked about. So we’ll move to Visual Studio in a minute, cuz I can create all these things in Visual Studio, as well. There’s a whole bunch of different languages. I’m gonna talk about predominantly C# cuz we’re gonna do a Visual Studio.

>> And the experience in Visual Studio is really, at the moment, in the V1, mainly tailored around the C# experience. But once I choose that, so you can see that most of these have the word trigger in them. So I have BlobTrigger, EventHubTrigger, GenericWebHook, GitHubWebHook, HttpTrigger.

>> Example, BlobTrigger, when somebody uploads a picture you want a notification sent to somebody.

>> Correct.

>> Right, this would be really easy to do here, and it’s all wired up.

>> Correct, and so what these templates do is, they basically give you much like our templates in Visual Studio do for other project types, is it generates the initial hookup for you, so that you have the right method with the right signature, taking the right input parameters. In a way that then, you just give it the connection string to point it to your blob storage or your queue, or something. Whatever you wanna register for the event for, you give it the connection string and now it’s listening and your code’s only gonna execute when something gets pushed into blob storage. So you said picture, right? Perfect example. Let’s say you have an endpoint, you want to do some processing on that picture, and then move it out of blob storage and store it somewhere else.

>> That could be a file, it could be a document.

>> Exactly, you wanna process the document, so you put a BlobTrigger. And once something goes into that blob storage, your function will execute, you can pick it up, you can process it. You’re only actually paying for, again kind of going back to the serverless thing, the resources that you’re using on demand gets pushed in. Code executes, processes it, sticks it somewhere else, code goes away, boom, you’re not paying for any resources any more. So it’s really event-based programming in the cloud. So the way that I have typically talked about Azure functions is, they’re kinda the glue that stitches a bunch of the other key Azure services together.

>> Right.

>> So storage queues, databases are kinda the most common examples of that. So let’s say you have a GitHubWebHook. So if you wanted to wire up and do something when a certain repository in GitHub gets pull requests or code gets pushed to that. You can basically write a function that would then pick up and do something and execute based on only when that event occurs. So, yeah, so what you talked about is they have this experience today to create these in the portal. Right now, I’ll just create a vanilla HttpTrigger which I already have here. And so let’s go ahead and say Develop. And so I have this browser in the portal that’s gonna show me my code, when it eventually loads. There you go. And so I can author it in the portal. It turns out for most Visual Studio customers, if you’re an existing .NET developer, you probably aren’t interested, or it’s not a very scalable solution for you to edit anything that’s super large while you’re in the browser. So what we’ve done is, in Visual Studio, we’ve shipped a preview.

It’s a separate download, so you can get to it from a blog post. So we have and you can find the blog post from me, Visual Studio Tools for Azure Functions.

>> And when that comes up.

>> I did find the blog post.

>> You did, yeah-

>> And then I emailed you and said you should come on the show [LAUGH].

>> Perfect, yeah, so it worked. So there’s a Getting Started section here, so what we have to have, there’s a couple prerequisites. So at the moment, the preview only works on top of Visual Studio 2015 Update 3.

>> Okay.

>> It does not yet work with Visual Studio 2017. And then you have to install the Azure 2.9.6 .NET SDK.

>> Okay.

>> And then you have to download and install our Visual Studio Tools for Azure Functions preview on top of that. So those, basically, those three things in that order and then what you will get, and we’ll go back to Visual Studio and take a look at it now. So I’m gonna say New Project. And what I should have is, I should have a Cloud node in here. And under Cloud node, I’m gonna see I have Azure Functions (Preview).

>> Hm-mm.

>> So I can go ahead and create my function app. I’m gonna go ahead and say OK, let’s go ahead and create function app. Boom, it’s up. It’s running. So now I have just a vanilla function app. So it has a couple things in here. So it has appsettings.json, which has by default two sort of placeholder connection strings. So what I’m gonna always have to do, all functions except for HTTP triggers, require a connection to a storage account. So I’m gonna provide a connection string to my storage account here. And then I have a host.json, which is where I can configure custom behavior. So in Azure, it turns out a lot of the events occur, it actually checks for events, so it’s more of a polling model as opposed to a true event trigger.

>> Okay.

>> And so what we’ll do going forward in a minute is, we’ll actually set up a QueueTrigger cuz it’s easy to play with using Storage Explorer. And I can change the interval by which it checks for items in the queue. So by default, it’ll be a minute, we use host.json to configure the behavior of things like that. So let’s go ahead and add a C# function. So let’s say Add > New Azure Function. And when I say New Azure Function I will see templates that match what I saw in the portal.

>> Yep.

>> So let’s go head down here. So I can filter, you can see that, again, we have a bunch of different languages. Bash, Batch, C#, F#, JavaScript, PHP, PowerShell.

>> You can write all of those inside Visual Studio.

>> You can write all of those inside Visual Studio. The experience that you have will depend on the components that you have installed in Visual Studio. So if you want Python IntelliSense for example, you need to install the Python Tools for Visual Studio. JavaScript IntelliSense should work because we support JavaScript in Visual Studio. But yeah, kind of, PowerShell you would need an extension, there are PowerShell extensions for Visual Studio, but if you wanted IntelliSense for that.

>> It’s funny that you would write Bash scripts inside Visual Studio.

>> Yeah, it’s possible.

>> That’s kind of [LAUGH].

>> Well, and again, that we’re mirroring the portal, so predominantly it’s not, that probably in some ways is much more of a Visual Studio code type experience.

>> Right.

>> And there are some extensions out there that support developing functions inside the code. A couple of them from Microsoft employees. But our team hasn’t shipped one.

>> Yeah, one yet.

>> Let’s just go ahead and filter our list to C#. Let’s go ahead and say QueueTrigger. And so what now I need to do is provide, so I think it was AzureWebJobsStorage, QueueTriggerCSharp is fine, Create. So what is this doing is this is actually.

>> And where’d that come from, AzureWebJobsStorage?

>> I’ll explain in a second.

>> Okay.

>> So that’s a great question. So this is the actually the name of the key in my app settings that is going to hold the connection string.

>> Okay.

>> So I click Create. So here in my appsettings.json, so yeah, it’s sort of a two-level in direction. So what I provided there was the name of the key that then holds the connection string.

>> I see, okay.

>> Does that make sense?

>> Yep.

>> And so I now have a QueueTriggerCSharp folder here. So this is gonna contain everything associated with the function that I just created.

>> Hm-mm. And if I wanted, a function project today is just a loose collection of folders, and each folder then contains your individual function. Currently, it’s based off of CSX, which is C# scripting, so it’s self-contained in each folder.

>> Okay.

>> But so I have a function.json and so you can see the function.json here. Contains the connection. And then, this is, so if I mistyped it or if I messed it up, I can come in here and fix that. I could put it in a different one. But as I mentioned, all functions require this actually particular value to be set pointing to a valid connection string. Let’s go ahead and open up Storage Explorer. So grab a connection string to a storage account here.

>> Should I also get that from the portal if you wanted.

>> I could, yes correct.

>> Sorry I need. Lovely, let’s see if this works. Sorry. [LAUGH] All right, I’m gonna need this to push, sorry. This reentering of credentials in Azure, if I’m not mistaken happens less often in 2017 than it was happening in 2016-

>> It should happen much less often. Now I have to turn my phone off of Airplane mode. Go factory authentication. Sorry, I should have fired this up.

>> That’s all right.

>> Okay.

>> Gives us an opportunity to talk about a new feature coming in 2017.

>> That’s right.

>> The need to reenter the credent to refresh the credentials happens fair amount in 2015. Maybe a little bit more than we’d like. And since you’re using your corporate account, if it was a Studio Enterprise account, which is our internal MSDN subscriptions. And it has two-factor authentication enabled, so it’s an extra step.

>> Correct, yeah.

>> Yeah, when I use my Microsoft account I just, it comes up with the password prepopulated, so you just click Enter. Sometimes you have to enter it, but it’s a lot faster.

>> Forgot to check keep me signed in. Which of course, sorry. This is actually Storage Explorer here, so.

>> Okay.

>> This isn’t Visual Studio 2017.

>> So this may not.

>> Yeah probably, this is just my fault

>> Okay.

>> Hadn’t logged into it in probably a couple of weeks on here.

>> Okay.

>> So, perfect. All right, there we go. So now we have all of our stuff, so I have andrewfunctionstorage. So let’s just go down here and pick my queue. And we should have a connection string down here somewhere. There we go, primary connection string. So what I’m going to do is I’m gonna go ahead and come back to here, and I’m gonna say, go ahead and paste that. So now that I have my connection string. What I’m gonna go ahead and do is I can go ahead and just hit F5 and start-

>> So you don’t need the dashboard? That’s optional, the other setting in there was the Azure web jobs dashboard.

>> I do not need the dashboard for the purpose of this. That just tells it where to send logging information. And so if I don’t specify this, I just won’t see any logging information in the portal. So, for example, if I go back here to my portal, when I click Run, there’s a logs that shows up down here. What that dashboard connection is doing is, it’s telling it where to send logging from things that I’m running locally back up to here. That’s not important for the purposes, unless you want to see in the portal, the logs of what you were doing locally. So what I can do now is, i’m just gonna go ahead and we have a vanilla thing, again, it’s a queue trigger and it’s based off of a queue. So it’s not gonna actually run until we push something into that queue. But i just wanna show what happens. So i can hit F5, and it’s gonna fire up a command prompt. And because this is scripting, it should dynamically compile it. You can see the little functions logo going on here. It’s now telling me that it’s up, it’s running, running locally.

Everything is running locally on my local machine, but it’s actually, and I can now see the job host started, so it started up successfully. And so let’s go ahead, and I mentioned we were going to modify our host.JSON in order to specify the queue interval. So I actually don’t remember off the top of my head, but we have IntelliSense, what the property here is for all of these. And so I wanna go ahead and say maxPollingInterval. And this is gonna be in milliseconds, so let’s make it 1000. So I’m gonna go ahead and update, cuz I think I have a queue in this Storage Explorer that’s already named. I don’t have a queue, so let’s go ahead and create a queue. And this was, what was this one over here, what do we call it? Myqueue items, so let’s go ahead and wire this up to this one. So queues, create new queue, myqueue-items, perfect. And so now, when I go ahead and hit F5 to start debugging this particular application, so I can Ctrl+F5 or I can F5. Debugging I mentioned, we were relatively C# centric, at the moment only works for C#.

>> Okay.

>> So any of the other app types, I could develop locally in Visual Studio

>> I could run, I could even hit F5, but I’m actually not gonna be able to debug and hit break points in them.

>> Yeah.

>> So let’s go ahead and just put a break point in here. And it’s not gonna do anything but log information and tell that we’ve processed it. We’re gonna go to our particular queue. We’re gonna add a new item. And then I’m gonna say, hi Robert. Let’s go ahead, boom, push it. And boom, we can now see that Visual Studio is hit, and the string that myQueueItem is Hi, Robert. So we just wrote a function that’s wired up to Azure Storage Queue. And so you can see, I mentioned it was event based, right? So it sat there for a while, while I was typing, and as soon as I said Submit, boom, we hit the break point. My function’s gonna process it. So I’m gonna go ahead and F5. Resume, I can now see here my logging as well. So it says function completed. C sharp queue trigger processed hi Robert. So I mentioned, if I was doing a JavaScript function or another language. I would see that I just wouldn’t be able to hit the break point in Visual Studio. And if I go back to my Azure Storage Explorer and I refresh, I’m gonna see that it’s now been removed from the queue, because it was processed by my Azure function.

>> Okay, cool.

>> So yeah, that’s kind of the. So, I guess the other thing we should talk about is what I want to do with a function once I’ve written it in Visual Studio, if I started it from Visual Studio and I want to actually go publish that to Azure. So before we do that, let’s talk a little bit more about scenarios. So let’s say you’re writing an app. It could be a mobile app, could be a desktop app, whatever, where you, we were talking about pictures or documents. You send those to Azure storage, and you want notifications to be sent out. So basically think about it, two ways to do it. The app itself could trigger the notification, but now that code is embedded in the app. And if you wanna change that processing, you gotta change the app. Is that correct architecturally?

>> Not 100% sure I followed your logic. I think you’re saying you have, let’s say you have a mobile app that you want to go process an image when somebody takes a picture.

>> Somebody sends an image up, or a doc, right? Somebody sends an image up. Now, you want other people to be notified of this, that an image has gone up.

>> Correct.

>> So how do you, what are your options for triggering that notification?

>> Yeah, so that one you would probably use Azure notifications for. And you could certainly use a function based on the Azure queue to kick off that notification.

>> Okay.

>> So you’d have a function that listens for that trigger in the blob storage trigger that hey, something arrived. And then yeah, you could have a little function code that would then basically use the Azure notification functionality to push those alerts back to the other mobile devices.

>> And that code would be where? In the app?

>> That would be in the Azure function.

>> In the Azure, okay, in the Azure function. So before Azure functions, you could send notifications using the notification hub, right? So I guess-

>> I think we might be slightly mixing some scenarios here.

>> No doubt. [LAUGH]

>> [LAUGH]

>> So let’s back up.


>> What I’m trying to get more of a sense of is, what is it that Azure functions gives me that I didn’t previously have?

>> Right.

>> So how does Azure functions make this scenario better slash easier?

>> Yeah, so, I think the way that Azure functions makes it better is before we had web jobs. And web jobs were largely based off of, you kinda had to go set a trigger to run on a certain interval. It didn’t necessarily have all these, or you had to write code in an app that was always on. That polled on a certain frequency all these potential events that can be occurring.

>> Okay.

>> And so what Azure functions to do is they really give you the plumbing by which to say, I want to run code when this event happens and you basically pass on a couple properties. So, think about what we just did. Pick the example that Rich had because it applies across blob storage and all these other events. He said, I want some code that runs and processes messages that get put in a queue. And I only want the code to execute, I only wanna pay for my time, my resources, when there’s something to process there. So we’ve said, new queue trigger, it could’ve been a blob storage trigger, it could’ve been a GitHub trigger, etc. We wrote, we plugged in one connection string and then we had code executing that was receiving as an input parameter to the function. The information that was being put in the queue.

>> Okay.

>> And what functions really do is they provide that sort of nice lightweight from a templated perspective glue to say when event X happens, let me run some code to process and handle that event. In a way that before, you would have might had to write a lot of custom code to do.

>> Okay, and so the code that goes inside this run method would potentially do things like trigger a notification, potentially send an email, potentially update a database somewhere.

>> Exactly.

>> Those types of things.

>> That’s a perfect example.

>> Okay.

>> So I might say, whenever information gets put in here, its gonna process it and put it in a database for example, that would be a good example. And we could write that code if we wanted, actually I think I have that code on my box already.

>> Okay, all right, cool.

>> Right, but I take the message in a queue. Actually I’ll just pull it up, cuz it’s a good example here. Open Azure solution, I’m pretty sure it’s function F1, forgive me if it’s not. Nope, function F1’s yeah it’s actually what I bought from the board post actually. It’s right, so we say, let’s take some code. And what it does is it reverses the message and then it pushes it into table storage.

>> Okay, yeah.

>> Right, so we say, here it says message, and then we say, we’re gonna push, for instance, what the original message was, we’re gonna reverse the message and then we’re gonna actually write it back into table storage. So a little more about permanent storage solution for our information rather than just keeping it in the queue. Cuz, right, it expires in the queue after a certain amount of time.

>> Yeah, okay, cool.

>> Does that answer your question?

>> Yeah.

>> So that’s why I kind of use the word before, it’s the glue. Like, in theory, you’re not gonna write an entire giant application inside the function. Not that you couldn’t but that’s probably not what you’re gonna do with it. Probably what you wanna do is all of those things. Hey, when something happens, I need to take data or information that occur over here, take some action on it.

>> Right.

>> And so that’s what functions allow you to do. And so they just provide that nice, lightweight glue and infrastructure in Azure such that you don’t have to have a service constantly running and pulling Azure handles all that on your behalf, and it just calls and executes your code whenever that event, only when that event occurs.

>> Cool.

>> All right?

>> Yeah.

>> Shall we move on?

>> Yes.

>> Great, so now I have my wonderful function here, that occurs when a queue happens. So let’s say I’ve written my super complex app, we’re gonna pretend that this is the next great thing that my mobile services are gonna call or whatever. So I’m gonna right-click and I’m going to say Publish, and so I wanna publish this to Microsoft Azure app service, that’s the only valid target for these at the moment. And so let’s go ahead and say, change my subscription here. So I have some work subscription associated with my account. And let’s go ahead and just put them in here, these are resource groups. So we can go ahead and create a new resource group if we want. So we’re just saying we’ll call it toolbox. And then I can go ahead and create a new function app, there’s a plan, there’s a couple of things to note here. So, there’s a couple different sizes associated with these. This is basically how much dedicated resources you want or you can say consumption. And what consumption does, is consumption says, only charge me for when the app is running.

So the other plans that I mentioned were, these were basically the size of the machine, what’s the limited resources that the apps gonna have.

>> Okay.

>> There is kind of a limit to my scalability based on how much I’m willing to max dedicate to it, right. So it’s this one, I can basically say, I’m willing to let these run on one machine with one core up to 1.75 GB of RAM. Consumption says you can scale as much as you need to, and you’re only gonna pay for what you use, but there’s no sort of limit on that. There are limits you can then place on the portal, you say I’m not willing to go above a dollar value and then they’ll stop executing or whatever, but-

>> So, if you’re just playing around with it, would you choose consumption or B1?

>> We’ll go B1 for now. There’s actually a known issue that’s a problem on the Azure side that they’re working on fixing. So it should be fixed in the near future, but basically with the consumption plan let me double check my known issues here to make sure that I’m not crazy on this. But they don’t necessarily get registered correctly for the triggers. And you just have to go into the portal and click refresh, there’s an easy work around.

>> Okay.

>> But that’s the only downside with the consumption base plan right now. And that’s a bug that should be fixed on the Azure side in the very near future. So hopefully a ton of people will watch this video it should be fixed but, so let’s just go ahead and just pick B1. Perfect, let’s go ahead and click Create. And so what this is gonna do now is this is gonna go ahead and provision all of the things up in Azure. So now when we go back in my portal I should see a resource group named toolbox. Once this finishes, and we’re dealing with the cloud, so it’s pretty quick. But it’ll still probably take us about 30 seconds or so because we’re creating new resource groups. We’re creating new associative storage accounts, things like that.

>> Right, and again, this is hooked up to your storage account. So anytime something happens in storage, regardless of where it came from, then that code will run. Is that correct?

>> Yeah, so what I did there’s actually two, yeah, so now I click Publish. Now it’s gonna actually push the code up into Azure. And so this should tell us when publish is complete. Yeah, so there’s two storage accounts that are associated. You can share the same or they can be different. So one is actually a storage account where my function code lives. So I have to have a storage account associated with the app service plan because, right, I’m pushing up assets here, C#, CSS scripts, project.json, host.json, app settings, right. All those types of things that needs a storage account for all those assets to live on. So that was in the provision notices what storage account do you wanna use. I can use an existing one. I can create a new one. Then, what I’ve done here is, I’ve wired via connection string, the function to listen to a storage account. I can listen to as many storage accounts as I want. I just have to have an associated storage account where the code actually resides in the cloud, right?

That CSX file has to physically exist on some medium somewhere-

>> Sure.

>> In the cloud. All right, so it’s telling us that publish succeeded. So let’s go ahead up to or back to our portal and let’s go look at my resource groups. And we expect now to see a toolbox resource group, perfect. It’s there, and so now, let’s go ahead and pick our function app. I should have given it a more meaningful name, but that’s okay. We’ve picked a unique name, so it guarantees that we can. And so I can see that i have my key trigger, C#. All right, so now we’re in the portal, we can see that we pushed our function app here. And that is actually what it’s doing. So, what we would expect now is if we would say save, it should be running. And so if I go push something into my storage explorer, it’s always dangerous to, oops, sorry, [LAUGH] wrong button. What I meant to do is go down here. Right, so let’s go to my, Trigger function app. So I should say if I push something into my queue, I would expect that my log files, if everything’s connected correctly-

>> Is it running?

>> It should be if the connection string’s got translated correctly. So what I would need to do is I would actually need to go into my function app settings and make sure that it’s connected up. So I guess it didn’t, it should have picked up the connection string from my, is this it? I can’t remember the right places. But anyway, you can see that we successfully got the code app there. So we don’t have to go in and say, sorry I forget the exact right place to find it, but it has to make sure I had the correct connection string. And as soon as I have the correct connection string, that setting got passed in correctly.

>> So is that something that happened in Visual Studio or during the publish process?

>> It should have happened during the publish process. So here it is. Both see if it picked it up correctly. And so it should have set an environment variable that had the Azure WebJobs storage. Looks like it did not. So what I can do then is I can go copy and paste my information from Visual Studio to, remember this is a V1 0.1 preview, so all these things don’t necessarily work as you would expect. But, sorry, app settings, that’s what I’m looking for. So I do that, that, the, and then let’s plug in the value. Back here, we’ll say boom. Remember it’s just a key value pair, so we’ll go ahead and save that. So now it’s connected to that function app, to that storage account trigger. And so now, if I come back in here, Oops, if I scroll to the correct place. When I say run, so-

>> That was the other one. Yeah. You’re right, I was in the wrong one. Blade UI got me. Yeah, so I connected a function that’s not, so I intentionally put something, this is an HTTP trigger. I’m in the wrong place. Let’s go into my Resource groups. So I don’t know if you want me to go through this. But that’s what you would do, is you’d go basically add that correct connection string, and then what I push to the portal would actually be working as we would expect.

>> Yeah, let’s see it work.

>> All right, let’s see it work. All right, so now, I say Function app settings. Configure app settings. Perfect. So AzureWebJobsStorage, okay, so it’s there.

>> Okay.

>> Let’s just make sure that we have the correct string. Boom, Save. All right, so it’s saved now. Just got to close this. Try to go back to my key function that says run. And so now, there you go, you can see the log tells me that it processed a message.

>> Okay.

>> So now if we go back and do another one, just to prove that we’re here. So refresh-

>> Is it connected to the right one?

>> Well, let’s find out. You know what? That’s a good question. So I need to go to my app settings.

>> You’re gonna set the right one in Azure storage.

>> Yeah, that’s a good question.

>> [INAUDIBLE] We’re debugging on the fly, we are.

>> So Save. So I think what I may need to do is, I may need to do is I need, let’s go back to the portal here. Say, QueueTrigger, Logs.

>> All right, so when you went into the Azure, to the storage tool when you were going to upload something into storage, were you uploading it to the one that this was attached to?

>> That is the question. That is the million dollar question. So I’m gonna say, function.json, so myqueue-test and here, this is myqueue-

>> Items, it’s not the right one.

>> My queue items that’s not the right one, so let’s fix that. Now, so that would be like here. There we go, so now it’s processing. So we got it connected up correctly.

>> Okay. Excellent [LAUGH].

>> So yes, the other cool things you can do in Visual Studio is let’s say, I actually wanted to debug this one in the Cloud. So I can go to Cloud Explorer. Using CTR+Q up here. And so I can point Visual Studio at my Azure functions. So I don’t want that. I want, Visual Studio Enterprise > App Service. Which one was this? What was the name of our function app? This is why I said I should’ve given it a better name. Just called function. Let’s go ahead and close this. So this was FunctionApp 13402. So 13402. Deployment Slots, and so now I can say Files. [LAUGH] That’s a bug that we’ve actually fixing recently, it happens sometimes. Of course, it happens right now.

>> Of course.

>> So the Cloud Explorer is the preferred method, but these also work from Server Explorer for now. So yep. So Azure, boom, Azure App Service. So these won’t appear quite right in Server Explorer, so Cloud Explorer’s been fixed to have the right icons

>> Mm-hm.

>> But we have, let’s go find toolbox, show that the functionality works the same. Here’s my FunctionApp > Files. So now I could go open up my QueueTrigger, run.csx. You can see it’s remote.

>> Mm.

>> So I can set a break point. We go back to Server Explorer, let me right-click and let me say, Attach Debugger. So this is gonna enable remote debugging on this app service in the Cloud.

>> That’s cool.

>> So the Cloud Explorer, while we’re waiting for this to attach, actually uses different APIs in Azure than Server Explorer.

>> Mm-hm.

>> And so we’re fixing Cloud Explorer to use the same APIs as Server Explorer, so we don’t run into that issue.

>> So you might decide that you actually write these in the portal because it’s easy. But then you come into Visual Studio for debugging.

>> Correct.

>> Cool.

>> Yeah, so I’ve actually done that. And actually, I’ve had issues much like right we just debugged some connection string type stuff, right? I’ve had other issues where I’ve written in Visual Studio everything worked locally, I’ve published them. It wasn’t just a it’s connected to the wrong storage account or something like that issue. And so what I’ve actually done is I’ve then gone and attached the debugger to figure out why it wasn’t working when I pushed it to Azure. There’s almost always some setting that didn’t get propagated correctly or something but it’s really, really useful. So now this should, once I add a message to the queue, let’s test this. Get hit here in a few seconds. Make sure that my function.JSON is working correctly, or that my host .JSON is the right. Where’s files? I wanna go up one level to see my polling interval. So it should have worked, it’s probably the polling interval, let’s see if I. Why did it not connect?

>> A preview.

>> It is a preview, yeah.

>> All right, but you should be able to-

>> Yeah, let me try this. Yeah, that works most of the time. I don’t know why it flaked out on me this time. It’s possible I picked the wrong function too. There’s a bunch of random numbers in there, right?

>> [LAUGH] Yeah.

>> But we should have modified the code too because they were different. But yeah, so remote debugging should work most of time. If it doesn’t, let us know.

>> All right, that’s awesome.

>> There’s certainly some bugs.

>> So this is in preview, people use it and have issues, where they should go?

>> Yeah, so I have a link on the blog post to file issues in the, I think it’s down here on GitHub repo.

>> Okay, cool.

>> So this is the Azure Functions repo, so any issues, right? So runtime issues or issues with the tools can all be filed there.

>> All right, great! So this is a preview in terms of, can you talk about timeframe for getting it, Readier?

>> I can tell you it will be after we ship Visual Studio 2017 RTM.

>> Okay, which is not that far away.

>> This is going to be our highest priority once we do that.

>> Okay.

>> So kind of we basically shipped the preview, we basically all the resources had to go into making sure that we were able to ship a high quality Visual Studio 2017.

>> Right, yep.

>> And so then once we do that, we will come back and start working on it.

>> Okay.

>> I can’t say what that exactly means for when we’ll be totally ready. But hopefully there will be minimum be more previews within the next few months.

>> Okay, cool. Will there be additional functionality? Or is it basically just getting it to all work?

>> There is some functionality that’s missing today. So I think there’s some broader, so the functions team for example, has added the ability to do statically compiled. So not just have script ones but actually precompile them into a class library and upload them. We don’t have any support for that.

>> Okay.

>> So yeah, there will be some more functionality. Today you can’t, this is just an unknown limitation but if I right-click I can’t add another CSX function. So if I say add new item, there’s actually no new item templates that support this project type currently.

>> Okay.

>> So yeah, definitely some of those limitations and bugs that we have.

>> All right.

>> We’ll fix.

>> So you’ll come back and you’ll show us this in the future?

>> Absolutely.

>> All right, cool, that’s awesome.

>> All right.

>> Thanks for coming on.

>> Thank you.

>> All right, hope you enjoyed that. Download it, play with it. Let Andrew know and the team know what you think. And we’ll see you next time on Visual Studio Toolbox.


Read the video

Note: This is a do-over of this episode. The first time Andrew and I recorded this, we weren’t happy with how it turned out. So we rerecorded the episode. Unfortunately, on 1/25 we accidentally published the version we didn’t like. We have now (1/31) updated this post with the second, much better version. We apologize for the mix-up.

In this episode, Robert is joined by Andrew Hall, who shows us a preview of tools for building Azure Functions for Visual Studio 2015. Azure Functions provide event-based serverless computing that make it easy to develop and scale your application, paying only for the resources your code consumes during execution. Andrew shows how to create a function project using C# in Visual Studio, run functions locally, and publish them to Azure. He also shows both local and remote debugging.


Comments to Visual Studio Tools for Azure Functions

  • ok 

    CaioAlexandre January 25, 2017 8:46 am Reply
  • Hi Andrew,Are azure functions suitable for long running process or they are designed to handle short only tasks ? For example: I tried using azure functions with media services for uploading and encoding videos, there it gives time out errors, it only runs for 5 minutes, I have choosen consumption plan for azure functions.Thanks,Kiran 

    KiranHoli February 3, 2017 1:30 am Reply
  • I experienced the same issue when attaching to the debugger to the function hosted in Azure. You seemed to just retry it at the end and it worked. is there something that you did to fix it? i coulnts see the files published in cloud explorer too

    mike February 4, 2017 3:19 pm Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

1Code.Blog - Your #1 Code Blog