|
| 1 | +import ConfigIcon from "@/assets/icons/logs.svg?react"; |
| 2 | +import { Codesnippet } from "@/components/CodeSnippet"; |
| 3 | +import { InfoBox } from "@/components/Infobox"; |
| 4 | +import { Numberbox } from "@/components/NumberBox"; |
| 5 | +import { ComponentBadge } from "@/components/stack-components/ComponentBadge"; |
| 6 | +import { Tick } from "@/components/Tick"; |
| 7 | +import { stackQueries } from "@/data/stacks"; |
| 8 | +import { useQuery } from "@tanstack/react-query"; |
| 9 | +import { Avatar, AvatarFallback, Skeleton, Spinner } from "@zenml-io/react-component-library"; |
| 10 | +import { useNewInfraFormContext } from "../NewInfraFormContext"; |
| 11 | +import { DeploymentButton } from "../Steps/Deploy/ButtonStep"; |
| 12 | +import { ComponentListItem, ProviderComponents } from "./index"; |
| 13 | +import { PermissionsCard } from "./PermissionsCard"; |
| 14 | + |
| 15 | +type Props = ProviderComponents; |
| 16 | + |
| 17 | +export function AzureComponents({ |
| 18 | + stackName, |
| 19 | + isLoading, |
| 20 | + isSuccess, |
| 21 | + components, |
| 22 | + displayPermissions = false |
| 23 | +}: Props) { |
| 24 | + return ( |
| 25 | + <div className="divide-y divide-theme-border-moderate overflow-hidden rounded-md border border-theme-border-moderate"> |
| 26 | + <div className="flex items-center gap-3 bg-theme-surface-secondary p-5 text-text-lg font-semibold"> |
| 27 | + {isLoading && <Spinner className="h-5 w-5 shrink-0 border-[3px]" />} |
| 28 | + {isSuccess && <Tick className="h-5 w-5" tickClasses="w-3 h-3" />} |
| 29 | + <Avatar type="square" size="lg"> |
| 30 | + <AvatarFallback size="lg">{stackName[0]}</AvatarFallback> |
| 31 | + </Avatar> |
| 32 | + {stackName} |
| 33 | + </div> |
| 34 | + <div className="space-y-1 py-3 pl-9 pr-5"> |
| 35 | + <ComponentListItem |
| 36 | + title={components?.connector?.name || "Azure Service Principal"} |
| 37 | + isLoading={isLoading} |
| 38 | + isSuccess={isSuccess} |
| 39 | + subtitle={components?.connector?.id || "Manage access to Azure resources"} |
| 40 | + badge={<ComponentBadge type="annotator">Service Connector</ComponentBadge>} |
| 41 | + img={{ |
| 42 | + src: "https://public-flavor-logos.s3.eu-central-1.amazonaws.com/service_connector/azure-service-principal.webp", |
| 43 | + alt: "Service Principal logo" |
| 44 | + }} |
| 45 | + /> |
| 46 | + {displayPermissions && <PermissionsCard />} |
| 47 | + </div> |
| 48 | + <div className="py-3 pl-9 pr-5"> |
| 49 | + <ComponentListItem |
| 50 | + title={components?.artifactStore?.name || "Azure Blob Storage"} |
| 51 | + subtitle={components?.artifactStore?.id || "Artifact storage for ML pipelines"} |
| 52 | + badge={<ComponentBadge type="artifact_store">Artifact Store</ComponentBadge>} |
| 53 | + isLoading={isLoading} |
| 54 | + isSuccess={isSuccess} |
| 55 | + img={{ |
| 56 | + src: "https://public-flavor-logos.s3.eu-central-1.amazonaws.com/artifact_store/azure.png", |
| 57 | + alt: "Blob Storage logo" |
| 58 | + }} |
| 59 | + /> |
| 60 | + </div> |
| 61 | + <div className="py-3 pl-9 pr-5"> |
| 62 | + <ComponentListItem |
| 63 | + title={components?.registry?.name || "Azure Container Registry"} |
| 64 | + subtitle={components?.registry?.id || "Container image storage"} |
| 65 | + badge={<ComponentBadge type="container_registry">Container Registry</ComponentBadge>} |
| 66 | + isLoading={isLoading} |
| 67 | + isSuccess={isSuccess} |
| 68 | + img={{ |
| 69 | + src: "https://public-flavor-logos.s3.eu-central-1.amazonaws.com/container_registry/azure.png", |
| 70 | + alt: "Azure Container Registry logo" |
| 71 | + }} |
| 72 | + /> |
| 73 | + </div> |
| 74 | + <div className="py-3 pl-9 pr-5"> |
| 75 | + <ComponentListItem |
| 76 | + title={components?.orchestrator?.name || "Azure Skypilot Orchestrator"} |
| 77 | + isLoading={isLoading} |
| 78 | + isSuccess={isSuccess} |
| 79 | + subtitle={components?.orchestrator?.id || "ML Workflow orchestration"} |
| 80 | + badge={<ComponentBadge type="orchestrator">Orchestrator</ComponentBadge>} |
| 81 | + img={{ |
| 82 | + src: "https://public-flavor-logos.s3.eu-central-1.amazonaws.com/orchestrator/azure-skypilot.png", |
| 83 | + alt: "Azure Skypilot logo" |
| 84 | + }} |
| 85 | + /> |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + ); |
| 89 | +} |
| 90 | + |
| 91 | +export function AzureInstructions({ displayInfobox = false }: { displayInfobox?: boolean }) { |
| 92 | + return ( |
| 93 | + <section className="space-y-5"> |
| 94 | + <AzureHeader /> |
| 95 | + <AzureDeploymentButton displayInfobox={displayInfobox} /> |
| 96 | + <CodeSnippetStep /> |
| 97 | + <CommandStep /> |
| 98 | + </section> |
| 99 | + ); |
| 100 | +} |
| 101 | + |
| 102 | +function AzureDeploymentButton({ displayInfobox = false }: { displayInfobox: boolean }) { |
| 103 | + return ( |
| 104 | + <div className="space-y-5"> |
| 105 | + <div className="space-y-1"> |
| 106 | + <div className="flex items-center gap-1"> |
| 107 | + <Numberbox>1</Numberbox> |
| 108 | + <span className="text-text-lg font-semibold">Open the Azure Cloud Shell Console</span> |
| 109 | + </div> |
| 110 | + <p className="text-theme-text-secondary"> |
| 111 | + Deploy the stack using the Azure Cloud Shell console. |
| 112 | + </p> |
| 113 | + </div> |
| 114 | + <DeploymentButton setTimestampBool> |
| 115 | + <span className="text-text-lg font-semibold">Open the Azure Cloud Shell</span> |
| 116 | + </DeploymentButton> |
| 117 | + {displayInfobox && ( |
| 118 | + <InfoBox className="border-warning-300 bg-warning-50" intent="warning"> |
| 119 | + After the Terraform deployment is complete, you can close the Cloud Shell session and |
| 120 | + return to the dashboard to view details about the associated ZenML stack automatically |
| 121 | + registered with ZenML. |
| 122 | + </InfoBox> |
| 123 | + )} |
| 124 | + </div> |
| 125 | + ); |
| 126 | +} |
| 127 | + |
| 128 | +function CodeSnippetStep() { |
| 129 | + return ( |
| 130 | + <div className="space-y-5"> |
| 131 | + <div className="space-y-1"> |
| 132 | + <div className="flex items-center gap-1"> |
| 133 | + <Numberbox>2</Numberbox> |
| 134 | + <span className="text-text-lg font-semibold"> |
| 135 | + Create a file with the following configuration |
| 136 | + </span> |
| 137 | + </div> |
| 138 | + <p className="text-theme-text-secondary"> |
| 139 | + Create a file named <code className="font-mono text-primary-400">main.tf</code> in the |
| 140 | + Cloud Shell and copy and paste the Terraform configuration below into it. |
| 141 | + </p> |
| 142 | + </div> |
| 143 | + <AzureCodesnippet /> |
| 144 | + </div> |
| 145 | + ); |
| 146 | +} |
| 147 | + |
| 148 | +function CommandStep() { |
| 149 | + return ( |
| 150 | + <div className="space-y-5"> |
| 151 | + <div className="space-y-1"> |
| 152 | + <div className="flex items-center gap-1"> |
| 153 | + <Numberbox>3</Numberbox> |
| 154 | + <span className="text-text-lg font-semibold">Run the following commands</span> |
| 155 | + </div> |
| 156 | + </div> |
| 157 | + <div> |
| 158 | + <p className="mb-1 text-text-sm text-theme-text-secondary"> |
| 159 | + Initialize the Terraform configuration. |
| 160 | + </p> |
| 161 | + <Codesnippet code="terraform init --upgrade" /> |
| 162 | + </div> |
| 163 | + <div> |
| 164 | + <p className="mb-1 text-text-sm text-theme-text-secondary"> |
| 165 | + Run terraform apply to deploy the ZenML stack to Azure. |
| 166 | + </p> |
| 167 | + <Codesnippet code="terraform apply" /> |
| 168 | + </div> |
| 169 | + </div> |
| 170 | + ); |
| 171 | +} |
| 172 | + |
| 173 | +function AzureCodesnippet() { |
| 174 | + const { data } = useNewInfraFormContext(); |
| 175 | + const deploymentConfig = useQuery({ |
| 176 | + ...stackQueries.stackDeploymentConfig({ |
| 177 | + provider: "azure", |
| 178 | + stack_name: data.stackName!, |
| 179 | + location: data.location |
| 180 | + }), |
| 181 | + enabled: !!data.stackName |
| 182 | + }); |
| 183 | + if (deploymentConfig.isError) return null; |
| 184 | + if (deploymentConfig.isPending) return <Skeleton className="h-[200px] w-full" />; |
| 185 | + |
| 186 | + return ( |
| 187 | + // This should be a unified component for gcp as well |
| 188 | + |
| 189 | + <Codesnippet |
| 190 | + fullWidth |
| 191 | + highlightCode |
| 192 | + codeClasses="whitespace-pre-wrap word-break-all" |
| 193 | + wrap |
| 194 | + code={deploymentConfig.data.configuration || ""} |
| 195 | + /> |
| 196 | + ); |
| 197 | +} |
| 198 | + |
| 199 | +function AzureHeader() { |
| 200 | + return ( |
| 201 | + <div className="space-y-1"> |
| 202 | + <p className="flex items-center gap-1 text-text-lg font-semibold"> |
| 203 | + <ConfigIcon className="h-5 w-5 fill-primary-400" /> |
| 204 | + Configuration |
| 205 | + </p> |
| 206 | + <p className="text-theme-text-secondary"> |
| 207 | + You will be asked to provide the following configuration values during the deployment |
| 208 | + process. |
| 209 | + </p> |
| 210 | + </div> |
| 211 | + ); |
| 212 | +} |
0 commit comments