Saturday, March 23, 2024

 

This is a continuation of a series of articles on Infrastructure-as-platform code, its shortcomings and resolutions.  IaC full service does not stop at just the provisioning of resources. The trust that the clients place on the IaC based deployment service is that their use cases will be enabled and remain operational without hassles. As an example, since we were discussing azure machine learning workspace, one of the use cases is to draw data from sources other than Azure provided storage accounts such as Snowflake. Execution of Snowflake on this workspace requires PySpark library and support from the java and Scala as well as jars specific to Snowflake.

This means that the workspace deployment will only be complete when the necessary prerequisites are installed. If the built-in doesn’t support, some customization is required. And in many cases, these come back to IaC configurations as much as there is automation possible via inclusion of scripts.

In this case of machine learning workspace, a custom kernel might be required for supporting snowflake workloads. Such a kernel can be installed by passing in an initialization script that writes out a kernel specification in yaml file that can in turn be used to initialize and activate the kernel. Additionally, the jars can be downloaded specific to Snowflake that includes their common library, support for Spark code execution and the official scala language execution jars.

Such a kernel might look something like this:

name: customkernel

channels:

  - conda-forge

  - defaults

dependencies:

  - python=3.11

  - numpy

  - pyspark

  - pip

  - pip:

    - azureml-core

    - ipython

    - ipykernel

    - pyspark==3.5.1

When the Spark session is started, the configuration specified can include the path to the jars. These additional steps must be taken to go the full length of onboarding customer workloads. Previous article references: IacResolutionsPart97.docx

Friday, March 22, 2024

 

You are given a 0-indexed integer array nums of length n.

You can perform the following operation as many times as you want:

  • Pick an index i that you haven’t picked before, and pick a prime p strictly less than nums[i], then subtract p from nums[i].

Return true if you can make nums a strictly increasing array using the above operation and false otherwise.

strictly increasing array is an array whose each element is strictly greater than its preceding element.

 

Example 1:

Input: nums = [4,9,6,10]

Output: true

Explanation: In the first operation: Pick i = 0 and p = 3, and then subtract 3 from nums[0], so that nums becomes [1,9,6,10].

In the second operation: i = 1, p = 7, subtract 7 from nums[1], so nums becomes equal to [1,2,6,10].

After the second operation, nums is sorted in strictly increasing order, so the answer is true.

Example 2:

Input: nums = [6,8,11,12]

Output: true

Explanation: Initially nums is sorted in strictly increasing order, so we don't need to make any operations.

Example 3:

Input: nums = [5,8,3]

Output: false

Explanation: It can be proven that there is no way to perform operations to make nums sorted in strictly increasing order, so the answer is false.

 

Constraints:

  • 1 <= nums.length <= 1000
  • 1 <= nums[i] <= 1000
  • nums.length == n

·        class Solution {

·            public boolean primeSubOperation(int[] nums) {

·                for (int i = 0; i < nums.length; i++) {

·                    int min = 0;

·                    if (i > 1) min = Math.max(nums[i-1], 0);

·                    int max = nums[i];

·                    int prime = getPrime(min, max);

·                    nums[i] -= prime;

·                }

·                return isIncreasing(nums);  

·            }

·            public boolean isIncreasing(int[] nums){

·                for (int i = 1; i < nums.length; i++){

·                    if (nums[i] <= nums[i-1]){

·                        return false;

·                    }

·                }

·                return true;

·            }

·            public int getPrime(int min, int max) {

·                for (int i = max-1; i > min; i--){

·                    if (isPrime(i) && (max – i > min)){

·                        return i;

·                    }

·                }

·                return 0;

·            }

·            public boolean isPrime(int n){

·                for (int i = 2; i < n; i++){

·                    if (n % i == 0) {

·                        return false;

·                    }

·                }

·                return true;

·            }

·        }

 

Thursday, March 21, 2024

 

In Azure public cloud, a virtual network (VNet) is a representation of your own network in the cloud. It allows you to securely connect Azure resources and extend your on-premises network to the cloud. A VNet is isolated and provides network-level segmentation and security. It also enables you to control inbound and outbound traffic using network security groups and virtual network service endpoints.

Peering is a feature in Azure that allows you to connect virtual networks together, both within the same region or across different regions. This enables resources in different virtual networks to communicate with each other using private IP addresses. There are two types of peering available in Azure:

  1. VNet peering: This allows you to connect virtual networks within the same region or different regions, as long as they belong to the same Azure subscription or different subscriptions within the same Azure Active Directory tenant. VNet peering is transitive, meaning that if VNet A is peered with VNet B, and VNet B is peered with VNet C, then VNet A can communicate with VNet C directly, without the need for a separate peering.
  2. Global VNet peering: This allows you to connect virtual networks across different Azure regions, regardless of whether they belong to the same subscription or Azure Active Directory tenant. Global VNet peering is also transitive, enabling communication between virtual networks in different regions.

Peering in Azure provides several benefits, including:

  • Reduced latency: With peering, you can achieve lower latency by establishing direct connections between virtual networks instead of going through public internet gateways.
  • Improved network performance: Peered virtual networks can communicate with each other at higher network speeds compared to traffic going through gateways.
  • Simplified network architecture: Peering allows you to create a flat network topology by connecting virtual networks together, simplifying network management and reducing the need for complex routing configurations.
  • Enhanced security: Peering enables secure communication between virtual networks using private IP addresses, ensuring that traffic remains within the Azure backbone network and is not exposed to the public internet.

Overall, virtual network and peering in Azure public cloud provide powerful capabilities for building and connecting networks in a secure and scalable manner..