DEV Community

Dave Brock
Dave Brock

Posted on • Originally published at daveabrock.com on

The .NET Stacks #36: ⚡ Azure Functions and some Microsoft history

Welcome to another week. If you’re seeing temperatures above above 0° F, please send some my way. Talk about a cold start—Azure Functions should be jealous.

This week:

  • OpenAPI support for Azure Functions
  • Achieving inheritance with Blazor CSS isolation
  • Ignoring calls from Bill Gates

Open API support for Azure Functions

When you create a new ASP.NET Core Web API in .NET 5, you may have noticed that Open API (more commonly to you, Swagger UI) is supported out of the box—and there’s a handy check mark in Visual Studio to guide you along. You might be wondering: will Open API support come to Azure Functions?

The answer is yes. While it’s very much in preview, the team’s been talking about releasing Open API bindings for Functions. This idea isn’t anything new, but the bindings look promising.

With bindings, you’ll be able to decorate your functions with bindings like:

  • [OpenApiOperation("addStuff", "stuff")]
  • [OpenApiRequestBody("application/json", typeof(MyRequestModel))]
  • [OpenApiResponseBody(HttpStatusCode.OK, "application/json", typeof(MyResponseModel))]

I’m seeing JSON.NET decorators (hat tip to the team for not pushing System.Text.Json on us), optional metadata configuration, and security and authentication support. It’s early, so if you do try it out be patient and report issues as you come across them.

Achieving inheritance with Blazor CSS isolation

After writing about Blazor CSS isolation over the last few months I’ve received a common question: how do I achieve inheritance with CSS isolation? I wrote about it this week.

The concept is a little weird—isolation scopes CSS to your components, and “inheriting” or sharing styles across components seems to go against a lot of those advantages. Even so, in some limited scenarios, it can help maintenance when dealing with similarly grouped components.

From the post (quoting myself in my newsletter deserves a trip to the therapist, I must admit):

If we’re honest, with Blazor CSS isolation, the “C” (cascading) is non-existent. There’s no cascading going on here—isolating your styles is the opposite of cascading. With Blazor CSS isolation, you scope your CSS component styles. Then, at build time, Blazor takes care of the cascading for you. When you wish to inherit styles and share them between components, you’re losing many of the advantages of using scoped CSS.

In my opinion, using inheritance with CSS isolation works best when you want to share styles across a small group of similar components. If you have 500 components in your solution and you want to have base styles across them all, you may be creating more problems for yourself. In those cases, you should stick with your existing tools.

With those caveats aside, how do you do it? The key here is that Blazor CSS isolation is file-based, not class-based, so it doesn’t know about your object graph. This is done with grouping custom scope identifiers, which you can add to your project file. I’ve included these updates in this week’s blog post and in the official Microsoft ASP.NET Core doc.

Ignoring calls from Bill Gates

I’ve really been enjoying reading Steven Sinofsky. A former Microsoft veteran—with stories to share from building out Windows in the antitrust years—he’s writing a serialized book on Substack, Hardcore Software. It’ll be split into 15 chapters and an epilogue. In his first chapter he writes about joining Microsoft. He never returned calls from Bill Gates because he thought his friends were pranking him. When he finally did, he was met with some hilarious frankness:

“Hi, Steve, this is Bill Gates.” … “Hello. Thank you for calling, and so sorry for the confusion. I thought a friend of mine…”

“So, David gave me this list of like ten people and I’m supposed to call all of them and convince them to work at Microsoft. You should come work at Microsoft. Do you have any questions?”

“Well, why haven’t you accepted yet? You have a good offer.”

“I’m considering other things. I have been really interested in government service.”

“Government? That’s for when you’re old and stupid.”

This is a fun history lesson and I’m looking forward to reading it all.

🌎 Last week in the .NET world

🔥 The Top 4

📢 Announcements

📅 Community and events

🌎 Web development

🥅 The .NET platform

⛅ The cloud

📔 Languages

🔧 Tools

📱 Xamarin

🎤 Podcasts

🎥 Videos

Top comments (0)