MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.2k stars 21.35k forks source link

ASA Bicep Template confusing and not complete #102825

Closed ezYakaEagle442 closed 6 months ago

ezYakaEagle442 commented 1 year ago

Regarding the Bicep Template with the ENTERPRISE Tier , The snippet provided is uncomplete and confusing :

resource agentPools 'Microsoft.AppPlatform/Spring/buildservices/agentPools@2022-03-01-preview' = {
  name: '${springCloudInstance.name}/default/default' //The only supported value is 'default'
}

resource springCloudMonitoringSettings 'Microsoft.AppPlatform/Spring/buildservices/builders/buildpackBindings@2022-03-01-preview' = {
  name: '${springCloudInstance.name}/default/default/default' //The only supported value is 'default'
  1. 'default' value is different from '/default/default/default'
  2. To ensure that value is enforced to be 'default' , it should be set with restristed values in Bicep parameters declaration :

For resource azureSpringAppsMonitoringSettings the name is '${azureSpringApps.name}/${buildServiceName}/${builderName}/${monitoringSettingsName}'

As the each 'default' value stands for , in this order :

  1. 'default' for Build Service name 'default'
  2. 'default' for Builder 'default'
  3. 'default' Build Pack binding name 'default'

so it is indeed: name: '${azureSpringApps.name}/${buildServiceName}/${builderName}/${monitoringSettingsName}'


@description('The Azure Spring Apps monitoring Settings name. Only "default" is supported')
@allowed([
  'default'
])
param monitoringSettingsName string = 'default'

@description('The Azure Spring Apps Service Registry name. Only "default" is supported')
@allowed([
  'default'
])
param serviceRegistryName string = 'default' // The resource name 'Azure Spring Apps Service Registry' is not valid

@description('The Azure Spring Apps Application Configuration Service name. Only "default" is supported')
@allowed([
  'default'
])
param applicationConfigurationServiceName string = 'default'

@description('The Azure Spring Apps API Portal name. Only "default" is supported')
@allowed([
  'default'
])
param apiPortalName string = 'default'

@description('The Azure Spring Apps Spring Cloud Gateway name. Only "default" is supported')
@allowed([
  'default'
])
param gatewayName string = 'default'

@allowed([
  'default'
])
@description('The Azure Spring Apps Application Configuration Service Git Repository name. Only "default" is supported')
param gitRepoName string  = 'default'

@description('The Azure Spring Apps Build Agent pool name. Only "default" is supported') // to be checked
@allowed([
  'default'
])
param buildAgentPoolName string = 'default'

@description('The Azure Spring Apps Build service name. Only "{azureSpringAppsInstanceName}/default" is supported') // to be checked
param buildServiceName string = 'default' 
resource azureSpringAppsMonitoringSettings 'Microsoft.AppPlatform/Spring/buildServices/builders/buildpackBindings@2022-11-01-preview' = if (azureSpringAppsTier=='Enterprise') {
  name: '${azureSpringApps.name}/${buildServiceName}/${builderName}/${monitoringSettingsName}' // default (for Build Service ) /default (Builder) /default (Build Pack binding name)
  properties: {
    bindingType: 'ApplicationInsights'
    launchProperties: {
      properties: {
        sampling_percentage: '10'
        connection_string: appInsights.properties.ConnectionString // /!\ ConnectionString for Enterprise tier ,  InstrumentationKey for Standard Tier 
      }
    }   
  }
  dependsOn: [
    buildService
  ]
}

configurationservices should be more detailed :

// https://learn.microsoft.com/en-us/azure/templates/microsoft.appplatform/2022-09-01-preview/spring/configurationservices?pivots=deployment-language-bicep
resource appconfigservice 'Microsoft.AppPlatform/Spring/configurationServices@2022-11-01-preview' = if (azureSpringAppsTier=='Enterprise') {
  name: applicationConfigurationServiceName
  parent: azureSpringApps
  properties: {
    settings: {
      gitProperty: {
        repositories: [
          {
            name: gitRepoName
            label: configServerLabel
            // https://learn.microsoft.com/en-us/azure/spring-apps/how-to-enterprise-application-configuration-service#pattern
            // {profile} - Optional. The name of a profile whose properties you may be retrieving. 
            // An empty value, or the value default, includes properties that are shared across profiles. 
            // Non-default values include properties for the specified profile and properties for the default profile.
            patterns: [
              'application'
            ]
            //searchPaths: [
            //  '/'
            //]
            uri: gitConfigURI
          }
        ]
      }
    }
  }
}

gateways should be more detailed

// https://learn.microsoft.com/en-us/azure/templates/microsoft.appplatform/2022-11-01-preview/spring/gateways?pivots=deployment-language-bicep
resource gateway 'Microsoft.AppPlatform/Spring/gateways@2022-11-01-preview' = if (azureSpringAppsTier=='Enterprise') {
  name: gatewayName
  parent: azureSpringApps
  sku: {
    name: azureSpringAppsSkuName
    capacity: any(1)
    tier: azureSpringAppsTier
  }
  properties: {
    corsProperties: {
      allowCredentials: false
      allowedOrigins: [
        '*'
      ]
      allowedMethods: [
        'GET'
      ]
      allowedHeaders: [
        '*'
      ]
    }
    httpsOnly: false
    public: true
    // az spring gateway update --help
    resourceRequests: {
      cpu: '1' // CPU resource quantity. Should be 500m or number of CPU cores.
      memory: '1Gi' // Memory resource quantity. Should be 512Mi or #Gi, e.g., 1Gi, 3Gi.
    }
    ssoProperties: {
      clientId: apiPortalSsoClientId
      clientSecret: apiPortalSsoClientSecret
      issuerUri: apiPortalSsoIssuerUri
      scope: [
        'openid'
        'profile'
        'email'
      ]
    }  
  }
}
output gatewayId string = gateway.id
output gatewayUrl string = gateway.properties.url

API Portal should be more detailed

resource apiPortal 'Microsoft.AppPlatform/Spring/apiPortals@2022-11-01-preview' = if (azureSpringAppsTier=='Enterprise') {
  name: apiPortalName
  parent: azureSpringApps
  sku: {
    name: azureSpringAppsSkuName
    capacity: any(1) // Number of instance ?
    tier: azureSpringAppsTier
  }
  properties: {
    gatewayIds: [
        '${azureSpringApps.id}/gateways/${gatewayName}'
      ]
    httpsOnly: false
    public: true
    ssoProperties: {
      clientId: apiPortalSsoClientId
      clientSecret: apiPortalSsoClientSecret
      issuerUri: apiPortalSsoIssuerUri
      scope: [
        'openid'
        'profile'
        'email'
      ]
    }
  }
}
output apiPortalId string = apiPortal.id
output apiPortalUrl string = apiPortal.properties.url
output gatewayIds array = apiPortal.properties.gatewayIds

routeConfigs should be provided :

resource CustomersGatewayRouteConfig 'Microsoft.AppPlatform/Spring/gateways/routeConfigs@2022-11-01-preview' = if (azureSpringAppsTier=='Enterprise') {
  name: 'customers-service-gateway-route-config'
  parent: gateway
  properties: {
    appResourceId: customersserviceapp.id
    protocol: 'HTTP'
    filters: [
      'StripPrefix=0'
    ]
    predicates: [
      '/api/customer/**'
      '/owners'
    ]
    routes: [
      {
        description: 'customers-service'
        title: 'customers-service'
        uri: 'http://customers-service'
        order: 1
        ssoEnabled: apiPortalSsoEnabled

      }
    ]
  }
}
output CustomersGatewayRouteConfigId string = CustomersGatewayRouteConfig.id
output CustomersGatewayRouteConfigAppResourceId string = CustomersGatewayRouteConfig.properties.appResourceId
output CustomersGatewayRouteConfigRoutes array = CustomersGatewayRouteConfig.properties.routes
output CustomersGatewayRouteConfigIsSsoEnabled bool = CustomersGatewayRouteConfig.properties.ssoEnabled
output CustomersGatewayRouteConfigPredicates array = CustomersGatewayRouteConfig.properties.predicates

App bindings should be detailed:

resource customersbinding 'Microsoft.AppPlatform/Spring/apps/bindings@2022-11-01-preview' = if (azureSpringAppsTier=='Enterprise') {
  name: 'customers-service-binding'
  parent: customersserviceapp
  properties: {
    bindingParameters: {}
    resourceId: customersserviceapp.id
    key: 'customers-service' // There is no API Key for MySQL
  }
  dependsOn: [
    serviceRegistry
  ]
}

The App should be detailed including the addonConfigs for applicationConfigurationService and serviceRegistry :

resource customersserviceapp 'Microsoft.AppPlatform/Spring/apps@2022-11-01-preview' = {
  name: 'customers-service'
  location: location
  parent: azureSpringApps
  identity: {
    type: 'UserAssigned'
    userAssignedIdentities: {
      '${customersServicedentity.id}': {}
    }      
  }
  properties: {
    addonConfigs: {
      azureMonitor: {
        enabled: true
      }
      applicationConfigurationService: {
        resourceId: '${azureSpringApps.id}/configurationServices/${applicationConfigurationServiceName}'
      }
      serviceRegistry: {
          resourceId: '${azureSpringApps.id}/serviceRegistries/${serviceRegistryName}'
      }      
      buildService: {
        resourceId: '${azureSpringApps.id}/buildServices/${buildServiceName}'
      }
    }
    httpsOnly: false
    public: true
    temporaryDisk: {
      mountPath: '/tmp'
      sizeInGB: 5
    }
  }
  dependsOn: [
    appconfigservice
  ]  
}

ALL the build services should be detailed, not only the agentPools :

resource buildService 'Microsoft.AppPlatform/Spring/buildServices@2022-11-01-preview' existing = if (azureSpringAppsTier=='Enterprise') {
  name: '${azureSpringAppsInstanceName}/${buildServiceName}' 
}

resource buildagentpool 'Microsoft.AppPlatform/Spring/buildServices/agentPools@2022-11-01-preview' = if (azureSpringAppsTier=='Enterprise') {
  // '{your-service-name}/default/default'  //{your-service-name}/{build-service-name}/{agenpool-name}
  name: '${azureSpringAppsInstanceName}/${buildServiceName}/${buildAgentPoolName}' // default/default as buildServiceName / agentpoolName
  properties: {
    poolSize: {
      name: 'S1'
    }
  }
  dependsOn: [
    azureSpringApps
    buildService
  ]  
}

// az spring build-service builder create --help
// https://learn.microsoft.com/en-us/azure/spring-apps/how-to-enterprise-build-service?tabs=azure-portal#default-builder-and-tanzu-buildpacks
resource builder 'Microsoft.AppPlatform/Spring/buildServices/builders@2022-11-01-preview' = if (azureSpringAppsTier=='Enterprise') {
  name: builderName
  parent: buildService
  properties: {
    buildpackGroups: [
      {
        buildpacks: [
          {
            id: 'tanzu-buildpacks/java-azure'
          }
        ]
        name: 'java'
      }
    ]
    // https://docs.vmware.com/en/VMware-Tanzu-Buildpacks/services/tanzu-buildpacks/GUID-full-stack-release-notes.html
    // 
    stack: {
      id: 'io.buildpacks.stacks.bionic' // io.buildpacks.stacks.bionic-base or tanzu-base-bionic-stack ?   https://docs.pivotal.io/tanzu-buildpacks/stacks.html , OSS from https://github.com/paketo-buildpacks/java
      version: 'base' // base or full 
    }
  }
  dependsOn: [
    azureSpringApps
  ]
}

// https://github.com/Azure/Azure-Spring-Apps/issues/28
resource build 'Microsoft.AppPlatform/Spring/buildServices/builds@2022-11-01-preview' = if (azureSpringAppsTier=='Enterprise') {
  name: buildName
  parent: buildService
  properties: {
    agentPool: buildagentpool.id
    builder: builder.id
    env: {}
    relativePath: '/'
  }
  dependsOn: [
    azureSpringApps
  ]
}
resource appAccelerators 'Microsoft.AppPlatform/Spring/applicationAccelerators@2022-11-01-preview' = if (azureSpringAppsTier=='Enterprise') {
 name: 'default'
 parent: azureSpringApps
 sku: {
   name: 'S1'
 }
}
output appAcceleratorsId string = appAccelerators.id
output appAcceleratorsComponents array = appAccelerators.properties.components

// az spring application-accelerator predefined-accelerator show -n "Acme Fitness Store" -g rg-iac-asa-petclinic-mic-srv
// Acme Fitness Store (does not work) or asa-acme-fitness-store ?
// Tanzu Java Restful Web App ? or asa-java-rest-service ?
// Node Express ? or asa-node-express ?
// Spring Cloud Serverless ? or asa-spring-cloud-serverless ? 
// C# Weather Forecast ? or asa-weatherforecast-csharp ?
resource predefinedAccelerators 'Microsoft.AppPlatform/Spring/applicationAccelerators/predefinedAccelerators@2022-11-01-preview' existing  = if (azureSpringAppsTier=='Enterprise') {
  name: 'asa-acme-fitness-store'
  parent: appAccelerators
}
output predefinedAcceleratorsId string = predefinedAccelerators.id
output predefinedAcceleratorsName string = predefinedAccelerators.name
output predefinedAcceleratorsDescription string = predefinedAccelerators.properties.description
resource appLiveViews 'Microsoft.AppPlatform/Spring/applicationLiveViews@2022-11-01-preview' = if (azureSpringAppsTier=='Enterprise') {
  name: 'default'
  parent: azureSpringApps
 }
 output appLiveViewsId string = appLiveViews.id
 output appLiveViewsComponents array = appLiveViews.properties.components

See Also https://github.com/Azure/Azure-Spring-Apps/issues/28


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

RamanathanChinnappan-MSFT commented 1 year ago

@ezYakaEagle442 I've delegated this to content author @KarlErickson to review and share his valuable insights.

KarlErickson commented 1 year ago

@ezYakaEagle442 apologies - I missed this earlier. Thanks for the feedback! I've informed the product team so they can take a look.

selvasingh commented 6 months ago

Please review and fix the doc

KarlErickson commented 6 months ago

We have represented this work in an Azure DevOps work item, and will investigate and fix.

please-close