Thursday, November 30, 2023

Azure AI Content Safety Service

Microsoft introduced a new AI service called “Azure AI Content Safety Service” at the Build conference in May 2023.  This new service will inspect for questionable content in any of the following categories.

  1. Violent content
  2. Hateful content
  3. Sexual content
  4. Self-harm content

 

The Content Safety service is intended to protect customers’ web sites and social media apps from receiving questionable comments or images.

Content maybe text, images, audio, video, or a combination of items (i.e. multi-modal). 

 

Users can utilize filters to tweak the severity levels.  For example, an outdoor equipment provider may allow images of knives or guns uploaded to their social media, but a school or church may like to prevent those images. Filters are set to Medium by default and can be increased.  Turning the filter settings to be less restricted or turned off requires a written application to Microsoft to ensure the customer is trusted and low risk.

 

The AI Content Safety Service is built into Open AI and most Microsoft AI products.  It’s used internally at Microsoft as well in public products like Bing Chat. The purpose is to uphold responsible AI principles provided by Microsoft.

 

 


 

Code Example

  1. Using the Azure AI Content Safety Service is accessible through the Azure portal. After logging into the portal, simply create a “Content Safety” Resource in an existing group or a new group.

 

  1. Once the resource is created, the Keys and Endpoints will be accessible in the Resource Management pane

 

 

  1. To access the Safety Content API, I created a console application with the following NuGet packages

 


 

  1. The code will utilize an API call, using the key and endpoint from step #2

 

using Azure;

using Azure.AI.ContentSafety;

using Microsoft.Extensions.Configuration;

using System.Reflection;

 

 

namespace AIContenSafety.ConsoleApp

{

    internal class Program

    {

        static void Main(string[] args)

        {

            var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();

            string endpoint = config["AppSettings:endpoint"];

            string key = config["AppSettings:key"];

 

            string datapath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images", "TestImage1.jpg");

 

            ImageData image = new ImageData();

            image.Content = BinaryData.FromBytes(File.ReadAllBytes(datapath));

 

            var request = new AnalyzeImageOptions(image);

 

            Response<AnalyzeImageResult> response;

            try

            {

                ContentSafetyClient client = new ContentSafetyClient(new Uri(endpoint), new AzureKeyCredential(key));

                response = client.AnalyzeImage(request);

            }

            catch (RequestFailedException ex)

            {

                Console.WriteLine("Analyze image failed.\nStatus code: {0}, Error code: {1}, Error message: {2}", ex.Status, ex.ErrorCode, ex.Message);

                throw;

            }

 

            Console.WriteLine("Hate severity: {0}", response.Value.HateResult.Severity);

            Console.WriteLine("SelfHarm severity: {0}", response.Value.SelfHarmResult.Severity);

            Console.WriteLine("Sexual severity: {0}", response.Value.SexualResult.Severity);

            Console.WriteLine("Violence severity: {0}", response.Value.ViolenceResult.Severity);

        }

    }

}

 

 

Testing the Application

Provided in the solution is a folder containing a test image (shown below), called TestImage1.jpg.  Naturally this image should be classified as violent content.

 

Running the Application

Executing the console application will load the test image specified above.  All results are posted in the console window showing the type of content violating the safety guidelines.  In addition, it shows the severity level of the content.

 

Additional Resources

Get started in Studio https://aka.ms/contentsafetystudio

Visit product page to learn more https://aka.ms/contentsafety

Read the eBook https://aka.ms/contentsafetyebook

 

Wednesday, October 18, 2023

Free OPEN Passes to API World 2023

API World 2023 (Oct 24-26, Santa Clara, CA) + (Oct 31- Nov 2, Live Online) is the world’s largest API & microservices event where 4,500+ engineers, architects, IT leaders, integration partners, API & technical professionals and executives converge to discover the latest API developer & engineering innovations. Learn from leaders at Microsoft, Apple, Cisco, Netflix, IBM, Adobe, Volkswagen AG, Airbnb, Realtor.com, US Bank, and many more!

The API World team has offered our group 25 free OPEN Passes and discounted PRO Passes, so our members can attend for free.

Register now to get your free OPEN Pass or to SAVE $100 on your PRO Pass.

To register, go to: https://www.devnetwork.com/registration/?event=API%20World%202023&utm_source=meetup&utm_medium=email&utm_campaign=MU21543&discount=MU21543

 

 

Friday, October 13, 2023

Using LocalDB in 3 Steps

Problem: While doing a demo on a client’s PC that didn’t have SQL Server Developer Edition installed, I needed a quick way to demonstrate querying a SQL Server DB without installing SQL Server.

 

Solution: LocalDB to the rescue!  The client’s PC did have SQL Server Management Studio installed, along with SQL Server Express.  This gave me enough capability to create a sample DB and demonstrate how to query it.

 

To create a DB instance:

  1. Open a Command Prompt window
  2. Enter “sqllocaldb create “Ch1Demo” “, where Ch1Demo was the specific name of my DB instance.  This short command quickly created an instance using the default version of the SQL Server DB Engine installed (see below).  This process was nearly instant (see below).

 

 

Since my username is “Sam”, The DB was created in the path C:\Users\Sam\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\Ch1Demo

 

  1. To connect to the DB instance, simply use SQL Server Management Studio with the Server Name preceded with “(localdb)\”

 

 

For all intents and purposes, Ch1Demo will appear as any other DB instance, allowing DB creation, updates, and queries.

 

 

This was the perfect solution in a pinch, and it helps you as well.

 

To learn more about localDB, visit https://learn.microsoft.com/en-us/sql/tools/sqllocaldb-utility?view=sql-server-ver16

 

Wednesday, October 11, 2023

Oct '23 Regional Tech Events

ChatGPT for Business

Recently David Giard (Microsoft) delivered a presentation on using ChatGPT.  Aside from answering basic questions, he demonstrated some key business and professional cases:

  • Create a LinkedIn Profile
  • Write a Professional email
  • “How do I increase my followers on Twitter?”
  • “How do I increase customer base?”
  • “How to organize a conference or event?”
  • Get ideas for writing, to prevent writers block

 

The full presentation can be seen at https://www.youtube.com/watch?v=noXxynTEEhg

 

 

 

 

 

 

 

Wednesday, May 10, 2023

Microsoft Azure Fundamentals Q&A

While attending a Microsoft Azure Fundamentals Training session today, some interesting questions were posted.  Listed below is the Q&A from the forum:

 

1.      How does private cloud differ from on-prem?

A private cloud may be hosted from your onsite datacenter, which would be on-premises. It may also be hosted in a dedicated datacenter offsite, potentially even by a third party that has dedicated that datacenter to your company. You can find more information here: https://learn.microsoft.com/en-us/training/modules/describe-cloud-compute/5-define-cloud-models

 

2.      Which is cheaper, public or hybrid cloud?

This depends on how your organization is structured, the size, and the services you need. You can compare on-premises and cloud costs using the Total Cost of Ownership Calculator here: https://azure.microsoft.com/en-us/pricing/tco/

 

3.      When to use private cloud (on prem) without [public] cloud ?

In some cases, your organization may be legally required to store information in your own data center. There may be other compliance and cost considerations as well. The size of your company and the resources you need may be less expensive in one form or another. You can find more information here: https://learn.microsoft.com/en-us/training/modules/describe-cloud-compute/5-define-cloud-models

 

4.      Does Hybrid cloud incurs both capital and operational expenditure?

Yes, hybrid cloud incurs both capital and operational expenditure.

 

5.      Is there any difference in availability of private and public cloud ?

There may be a difference in availability depending on the circumstances. If you have older technology in your private cloud, you may have more latency. Or, if you have resources on the other side of the globe in the public cloud, you may also have latency. There are many variables.

 

6.      What’s the definition for public cloud?

A public cloud is built, controlled, and maintained by a third-party cloud provider. You can find more information here: https://learn.microsoft.com/en-us/training/modules/describe-cloud-compute/5-define-cloud-models

 

7.      Does "Private Cloud" mean some form on on-prem Azure or AWS, etc.?

Azure and AWS are examples of Public Cloud. This is the opposite of private cloud. with Private cloud, you are owning/operating your own resources. With public cloud, your provider owns and operates the hardware. You can find more information here: https://learn.microsoft.com/en-us/training/modules/describe-cloud-compute/5-define-cloud-models

 

8.      Would you explain the difference between elasticity and scalability?

Scalability means increasing or decreasing services as needed. Elasticity refers to enabling the increase or decrease of automatically: When a resource meets a limit, it will automatically increase as needed.

 

9.      If I create a VM in Cloud, will I be charged even if VM is shut down?

Yes, because your VM is still taking up storage space. You will not be charged for run time if it is not running, though.

 

10.   Does Azure provide private cloud capabilities if customer demands?

Yes, there are some options for organizations to have dedicated hardware. One example is with Azure dedicated host. More information about that is available here: https://learn.microsoft.com/en-us/azure/virtual-machines/dedicated-hosts  

 

11.   Please provide definition for CAPEX

CapEx refers to Capital Expenditure and is typically a one-time, up-front expenditure to purchase or secure tangible resources. A new building, repaving the parking lot, building a datacenter, or buying a company vehicle are examples of CapEx. You can find more information here: learn.microsoft.com/en-us/training/modules/describe-cloud-compute/6-describe-consumption-based-model

 

12.   Do Microsoft Azure has a data center in the continent of Antarctica?

Great question. I don't see one in Antarctica. You can find the list here: https://azure.microsoft.com/en-us/explore/global-infrastructure/geographies/#choose-your-region  

Friday, January 20, 2023

7 Ways to Reduce Azure Costs

Listed below are 7 ways to reduce your Azure monthly cost.


1. Shut down unused resources

Use Azure Advisor to identify idle virtual machines (VMs), ExpressRoute circuits, and other unused resources.


2. Right-size underused resources

Find resources not fully utilized with Azure Advisor.  It will also provide recommendations on reconfiguring resources to reduce cost.


3. Reserve instances for consistent workloads

Use reservation pricing to pre-pay for resources for a 1 or 3 year term.  This could result in a discount of up to 72% over pay-as-you-go pricing on Azure services.


4.
Take advantage of the Azure Hybrid Benefit

Have existing on-premises software licenses?  Use them with Azure for no additional cost and select Azure services for free.


5. Configure autoscaling

Avoid the high cost of hardware investment used only during peak times of the year.  Instead, dynamically allocate and de-allocate resources to match your business needs when you need it.


6. Set up budgets and allocate costs to teams and projects

Use Microsoft Cost Management to create and manage budgets of Azure services used, and monitor your organization’s cloud spending.


7. Choose the right Azure compute service

Azure offers a variety of resources, with varying degrees of management.  Depending on the level of resource management you choose, the monthly spend can be reduced significantly. Use the following diagrams to identify the various resources and management needs.

 

 

Diagram Reference: https://medium.com/chenjd-xyz/azure-fundamental-iaas-paas-saas-973e0c406de7