@@ -23,6 +23,7 @@ import (
23
23
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
24
24
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
25
25
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices"
26
+ "github.com/azure/azure-dev/cli/azd/internal"
26
27
"github.com/azure/azure-dev/cli/azd/pkg/account"
27
28
"github.com/azure/azure-dev/cli/azd/pkg/async"
28
29
"github.com/azure/azure-dev/cli/azd/pkg/azapi"
@@ -77,6 +78,7 @@ type BicepProvider struct {
77
78
portalUrlBase string
78
79
subscriptionManager * account.SubscriptionsManager
79
80
azureClient * azapi.AzureClient
81
+ userConfigManager config.UserConfigManager
80
82
}
81
83
82
84
// Name gets the name of the infra provider
@@ -611,16 +613,33 @@ func (p *BicepProvider) Deploy(ctx context.Context) (*provisioning.DeployResult,
611
613
return nil , err
612
614
}
613
615
614
- err = p .validatePreflight (
615
- ctx ,
616
- bicepDeploymentData .Target ,
617
- bicepDeploymentData .CompiledBicep .RawArmTemplate ,
618
- bicepDeploymentData .CompiledBicep .Parameters ,
619
- deploymentTags ,
620
- optionsMap ,
621
- )
616
+ userConfig , err := p .userConfigManager .Load ()
622
617
if err != nil {
623
- return nil , err
618
+ return nil , fmt .Errorf ("loading user configuration: %w" , err )
619
+ }
620
+
621
+ preflightDisableVar := "provision.disableValidation"
622
+ preflightDisable , exists := userConfig .GetString (preflightDisableVar )
623
+ if ! (preflightDisable == "on" && exists ) {
624
+ err = p .validatePreflight (
625
+ ctx ,
626
+ bicepDeploymentData .Target ,
627
+ bicepDeploymentData .CompiledBicep .RawArmTemplate ,
628
+ bicepDeploymentData .CompiledBicep .Parameters ,
629
+ deploymentTags ,
630
+ optionsMap ,
631
+ )
632
+ if err != nil {
633
+ return nil , & internal.ErrorWithSuggestion {
634
+ Err : err ,
635
+ Suggestion : fmt .Sprintf ("To disable provision validation, please run %s." ,
636
+ output .WithHighLightFormat ("`azd config set %s on`" , preflightDisableVar )),
637
+ }
638
+ }
639
+ } else {
640
+ warningMessage := fmt .Sprintf ("WARNING: Provision validation is disabled. To enable it, please run `azd config set %s off`.\n " ,
641
+ preflightDisableVar )
642
+ p .console .Message (ctx , output .WithWarningFormat (warningMessage ))
624
643
}
625
644
626
645
cancelProgress := make (chan bool )
@@ -2164,6 +2183,7 @@ func NewBicepProvider(
2164
2183
cloud * cloud.Cloud ,
2165
2184
subscriptionManager * account.SubscriptionsManager ,
2166
2185
azureClient * azapi.AzureClient ,
2186
+ userConfigManager config.UserConfigManager ,
2167
2187
) provisioning.Provider {
2168
2188
return & BicepProvider {
2169
2189
envManager : envManager ,
@@ -2179,5 +2199,6 @@ func NewBicepProvider(
2179
2199
portalUrlBase : cloud .PortalUrlBase ,
2180
2200
subscriptionManager : subscriptionManager ,
2181
2201
azureClient : azureClient ,
2202
+ userConfigManager : userConfigManager ,
2182
2203
}
2183
2204
}
0 commit comments