Powershell AZ Module Update

Recently was trying to build the Azure Bicep templates and tried executing them from Powershell. In order to use Bicep the AZ powershell modules should be using v5.6.0 or later.

Read More

Azure: Bicep Deployment Error - Another operation on this or dependent resource is in progress

I had been working on converting the ARM templates into Bicep by writing from scratch. One of the reason was the learning curve (by writing from scratch it will give a better understanding) and the other was complex ARM templates do give an error when trying to decompile.

I noticed one annoying issue for a simple tasks as deploying a virtual network with multiple subnets - dependency / another operation in progress [see below error]. As far as i have read, Bicep should be able to calculate the dependencies automatically without explicitly defining in the code but that does not work always.

bicep error

Solution: The updated code contains a dependsOn parameter (similar to ARM Templates) as part of the subnet blocks (except the first subnet). What this allows is to create a sequential deployment of the subnets within the virtual network.

Here is the original code:

resource firewallSubnetResource 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' = {
  name: '${mainVirtualNetworkResource.name}/${mainVirtualNetwork.firewallSubnetName}'
  properties: {
    addressPrefix: mainVirtualNetwork.firewallSubnetSpace
    delegations: []
    privateEndpointNetworkPolicies: 'Disabled'
    privateLinkServiceNetworkPolicies: 'Disabled'
  }
}

resource appSubnetResource 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' = {
  name: '${mainVirtualNetworkResource.name}/${mainVirtualNetwork.mainSubnetName}'
  properties: {
    addressPrefix: mainVirtualNetwork.mainSubnetSpace
    delegations: []
    privateEndpointNetworkPolicies: 'Disabled'
    privateLinkServiceNetworkPolicies: 'Disabled'
  }
}

resource managementSubnetResource 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' = {
  name: '${mainVirtualNetworkResource.name}/${mainVirtualNetwork.managementSubnetName}'
  properties: {
    addressPrefix: mainVirtualNetwork.managementSubnetSpace
    delegations: []
    privateEndpointNetworkPolicies: 'Disabled'
    privateLinkServiceNetworkPolicies: 'Disabled'
  }
}

resource bastionSubnetResource 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' = {
  name: '${mainVirtualNetworkResource.name}/${mainVirtualNetwork.bastionSubnetName}'
  properties: {
    addressPrefix: mainVirtualNetwork.bastionSubnetSpace
    delegations: []
    privateEndpointNetworkPolicies: 'Disabled'
    privateLinkServiceNetworkPolicies: 'Disabled'
  }
}

resource aaddsSubnetResource 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' = {
  name: '${mainVirtualNetworkResource.name}/${mainVirtualNetwork.aaddsSubnetName}'
  properties: {
    addressPrefix: mainVirtualNetwork.aaddsSubnetSpace
    delegations: []
    privateEndpointNetworkPolicies: 'Disabled'
    privateLinkServiceNetworkPolicies: 'Disabled'
  }
}

resource mainVirtualNetworkResource 'Microsoft.Network/virtualNetworks@2020-11-01' = {
  name: virtualNetworkName
  location: location
  properties: {
    addressSpace: {
      addressPrefixes: [
        mainVirtualNetwork.addressSpace
      ]
    }
    enableDdosProtection: false
  }
}

Updated code:

resource firewallSubnetResource 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' = {
  name: '${mainVirtualNetworkResource.name}/${mainVirtualNetwork.firewallSubnetName}'
  properties: {
    addressPrefix: mainVirtualNetwork.firewallSubnetSpace
    delegations: []
    privateEndpointNetworkPolicies: 'Disabled'
    privateLinkServiceNetworkPolicies: 'Disabled'
  }
}

resource appSubnetResource 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' = {
  name: '${mainVirtualNetworkResource.name}/${mainVirtualNetwork.mainSubnetName}'
  properties: {
    addressPrefix: mainVirtualNetwork.mainSubnetSpace
    delegations: []
    privateEndpointNetworkPolicies: 'Disabled'
    privateLinkServiceNetworkPolicies: 'Disabled'
  }
  dependsOn: [
    firewallSubnetResource
  ]
}

resource managementSubnetResource 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' = {
  name: '${mainVirtualNetworkResource.name}/${mainVirtualNetwork.managementSubnetName}'
  properties: {
    addressPrefix: mainVirtualNetwork.managementSubnetSpace
    delegations: []
    privateEndpointNetworkPolicies: 'Disabled'
    privateLinkServiceNetworkPolicies: 'Disabled'
  }
  dependsOn: [
    appSubnetResource
  ]
}

resource bastionSubnetResource 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' = {
  name: '${mainVirtualNetworkResource.name}/${mainVirtualNetwork.bastionSubnetName}'
  properties: {
    addressPrefix: mainVirtualNetwork.bastionSubnetSpace
    delegations: []
    privateEndpointNetworkPolicies: 'Disabled'
    privateLinkServiceNetworkPolicies: 'Disabled'
  }
  dependsOn: [
    managementSubnetResource
  ]
}

resource aaddsSubnetResource 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' = {
  name: '${mainVirtualNetworkResource.name}/${mainVirtualNetwork.aaddsSubnetName}'
  properties: {
    addressPrefix: mainVirtualNetwork.aaddsSubnetSpace
    delegations: []
    privateEndpointNetworkPolicies: 'Disabled'
    privateLinkServiceNetworkPolicies: 'Disabled'
  }
  dependsOn: [
    bastionSubnetResource
  ]
}

resource mainVirtualNetworkResource 'Microsoft.Network/virtualNetworks@2020-11-01' = {
  name: virtualNetworkName
  location: location
  properties: {
    addressSpace: {
      addressPrefixes: [
        mainVirtualNetwork.addressSpace
      ]
    }
    enableDdosProtection: false
  }
}
Read More

Javascript Shorthand

There are various javascript shorthand techniques available for a more productive development process and clean coding style. Here are some of the few shorthand techniques:

Read More

Connect to Azure DevOps Repository

I was struggling to find the right set of instruction to connect Jenkins with Azure Devops Git Repository. Howevery after many attempts on getting Jenkins Build to fetch the git repository from Azure Devops worked.

Read More

Installing Rancher 1.6 on Ubuntu 18.04 (and newer)

I had been trying to find a tool that would allow management of K8s cluster or standalone docker containers. After much of research found that rancher works well with k8s cluster and standalone containers. However, the challenge was getting it to work, the installation is not straightforward and the user guides available have some or the other steps missing.

Read More
  rancher   k8s   kubernetes   docker   docker-compose   ubuntu   linux   jenkins   azure   devops   javascript   shorthand   js   cheatsheet   bicep   deployment   error   arm   templates   jekyll   "code   highlight"   css   powershell   module   automation   azuresql   elasticpool   fsx   ontap   netapp   fsxn   AWS   Cloud