import { Field, Form, Formik } from 'formik'; import { useCurrentStateAndParams, useRouter } from '@uirouter/react'; import { FormControl } from '@/portainer/components/form-components/FormControl'; import { Input, Select } from '@/portainer/components/form-components/Input'; import { FormSectionTitle } from '@/portainer/components/form-components/FormSectionTitle'; import { LoadingButton } from '@/portainer/components/Button/LoadingButton'; import { InputListError } from '@/portainer/components/form-components/InputList/InputList'; import { ContainerInstanceFormValues } from '@/azure/types'; import * as notifications from '@/portainer/services/notifications'; import { useUser } from '@/portainer/hooks/useUser'; import { AccessControlForm } from '@/portainer/access-control/AccessControlForm'; import { validationSchema } from './CreateContainerInstanceForm.validation'; import { PortMapping, PortsMappingField } from './PortsMappingField'; import { useLoadFormState } from './useLoadFormState'; import { getSubscriptionLocations, getSubscriptionResourceGroups, } from './utils'; import { useCreateInstance } from './useCreateInstanceMutation'; export function CreateContainerInstanceForm() { const { params: { endpointId: environmentId }, } = useCurrentStateAndParams(); if (!environmentId) { throw new Error('endpointId url param is required'); } const { isAdmin } = useUser(); const { initialValues, isLoading, providers, subscriptions, resourceGroups } = useLoadFormState(environmentId, isAdmin); const router = useRouter(); const { mutateAsync } = useCreateInstance(resourceGroups, environmentId); if (isLoading) { return null; } return ( initialValues={initialValues} validationSchema={() => validationSchema(isAdmin)} onSubmit={onSubmit} validateOnMount validateOnChange enableReinitialize > {({ errors, handleSubmit, isSubmitting, isValid, values, setFieldValue, }) => (
Azure settings Container configuration setFieldValue('ports', value)} errors={errors.ports as InputListError[]} />
This will automatically deploy a container with a public IP address
Container Resources setFieldValue('accessControl', values)} values={values.accessControl} errors={errors.accessControl} />